Improve performance of is defined in non strict mode
authornikic <nikita.ppv@googlemail.com>
Sat, 2 Jul 2011 09:20:54 +0000 (11:20 +0200)
committernikic <nikita.ppv@googlemail.com>
Sat, 2 Jul 2011 09:21:49 +0000 (11:21 +0200)
lib/Twig/Node/Expression/GetAttr.php

index 2208c9e..fcf50f6 100644 (file)
@@ -20,7 +20,9 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
     {
         $compiler->raw('$this->getAttribute(');
 
-        if ($this->hasAttribute('is_defined_test')) {
+        if ($this->hasAttribute('is_defined_test')
+            && $compiler->getEnvironment()->isStrictVariables()
+        ) {
             $compiler->subcompile(new Twig_Node_Expression_Filter(
                 $this->getNode('node'),
                 new Twig_Node_Expression_Constant('default', $this->getLine()),