From: Fabien Potencier Date: Sat, 21 Jan 2012 20:26:04 +0000 (+0100) Subject: Revert "made a speed optimization to macro calls when imported via the from tag" X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=88389ac5035beba2e6a88ec8db188cb5ed39d3b7;p=web%2Fkonrad%2Ftwig.git Revert "made a speed optimization to macro calls when imported via the from tag" This reverts commit 3b87da344ade9a719d3e105eb7ca20864b725875. --- diff --git a/CHANGELOG b/CHANGELOG index 5d2ab67..75cd2e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,5 @@ * 1.6.0-DEV - * made a speed optimization to macro calls when imported via the "from" tag * added slice notation support for the [] operator (syntactic sugar for the slice operator) * added a slice filter * added string support for the reverse filter diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index dfe7f03..ddbdc8f 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -309,7 +309,7 @@ class Twig_ExpressionParser return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : new Twig_Node_Expression_Array(array(), $line), Twig_TemplateInterface::ANY_CALL, $line); default: if (null !== $alias = $this->parser->getImportedFunction($name)) { - return new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $args, $line); + return new Twig_Node_Expression_GetAttr($alias['node'], new Twig_Node_Expression_Constant($alias['name'], $line), $args, Twig_TemplateInterface::METHOD_CALL, $line); } $class = $this->getFunctionNodeClass($name); diff --git a/lib/Twig/Node/Expression/MethodCall.php b/lib/Twig/Node/Expression/MethodCall.php deleted file mode 100644 index 19d4e76..0000000 --- a/lib/Twig/Node/Expression/MethodCall.php +++ /dev/null @@ -1,36 +0,0 @@ - $node, 'arguments' => $arguments), array('method' => $method), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->subcompile($this->getNode('node')) - ->raw('->') - ->raw($this->getAttribute('method')) - ->raw('(') - ; - $nodes = $this->getNode('arguments'); - for ($i = 0, $max = count($nodes); $i < $max; $i++) { - $compiler->subcompile($nodes->getNode($i)); - - if ($i < $max - 1) { - $compiler->raw(', '); - } - } - $compiler->raw(')'); - } -} diff --git a/lib/Twig/TokenParser/From.php b/lib/Twig/TokenParser/From.php index 4e20f5c..ba4d7ff 100644 --- a/lib/Twig/TokenParser/From.php +++ b/lib/Twig/TokenParser/From.php @@ -56,7 +56,7 @@ class Twig_TokenParser_From extends Twig_TokenParser $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); foreach($targets as $name => $alias) { - $this->parser->addImportedFunction($alias, 'get'.$name, $node->getNode('var')); + $this->parser->addImportedFunction($alias, $name, $node->getNode('var')); } return $node;