From: Fabien Potencier Date: Tue, 12 Jul 2011 07:49:06 +0000 (+0200) Subject: merged branch nikic/optimizeVariableAccess2 (PR #382) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=0ef96f6b1ddd2b395ab6476482fb4461e4036ec2;p=konrad%2Ftwig.git merged branch nikic/optimizeVariableAccess2 (PR #382) Commits ------- 5b91f12 Update tests a5ef326 Use Template->getContext in non-strict mode too Discussion ---------- Use Template->getContext() when in non-strict mode, too As described in #380 using the current `isset($context['test']) ? $context['test'] : null` approach can cause problems in some cases: The ternary operator always returns by value and thus PHP's copy-on-write concept does not apply. So `$context['test']` needs to be copied in any case, even though a write never happens to it. Basically Twig is copying the values of all variables ever used inside Twig if it operates in non-strict mode. This is problematic when `$context['test']` contains big arrays as the whole array is copied. In this patch I change Twig to use `Template->getContext` when in non-strict mode too and add an `isStrictVariables` check in there. --- 0ef96f6b1ddd2b395ab6476482fb4461e4036ec2