From 229239a0b07b7eeae1a256bd84fd20de209e0a1e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 19 Feb 2012 11:03:22 +0100 Subject: [PATCH] Revert "merged branch m0ppers/master (PR #611)" This reverts commit 5f4e6d7a0eae30791e9e1433c90b157bcb5dc8f7, reversing changes made to a61d42084caeadc4cc8c3bd1caded87631c12636. --- lib/Twig/Node/Expression/Name.php | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/Twig/Node/Expression/Name.php b/lib/Twig/Node/Expression/Name.php index a8d206f..4b8d541 100644 --- a/lib/Twig/Node/Expression/Name.php +++ b/lib/Twig/Node/Expression/Name.php @@ -35,18 +35,29 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression } elseif ($this->isSpecial()) { $compiler->raw($this->specialVars[$name]); } else { - $compiler - ->raw('$this->getContext($context, ') - ->string($name) - ; + if (version_compare(phpversion(), '5.4.0RC1', '>=') && ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables())) { + // PHP 5.4 ternary operator performance was optimized + $compiler + ->raw('(isset($context[') + ->string($name) + ->raw(']) ? $context[') + ->string($name) + ->raw('] : null)') + ; + } else { + $compiler + ->raw('$this->getContext($context, ') + ->string($name) + ; - if ($this->getAttribute('ignore_strict_check')) { - $compiler->raw(', true'); - } + if ($this->getAttribute('ignore_strict_check')) { + $compiler->raw(', true'); + } - $compiler - ->raw(')') - ; + $compiler + ->raw(')') + ; + } } } -- 1.7.2.5