From 93bee55d33da21ff62dc34664299d0617911b691 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 18 Sep 2017 09:23:40 +0200 Subject: [PATCH] =?UTF-8?q?=C2=B5optim=20for=20twig=5Fget=5Fattribute()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Twig/Extension/Core.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 25fd9d8d1..ae62de603 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -1430,8 +1430,6 @@ function twig_array_batch($items, $size, $fill = null) */ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false) { - static $cache = array(); - // array if (Twig_Template::METHOD_CALL !== $type) { $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item; @@ -1518,6 +1516,8 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, } } + static $cache = array(); + $class = get_class($object); // object method