mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Optimize resume after for loops by using + vs array_merge
This commit is contained in:
@@ -107,6 +107,6 @@ class Twig_Node_For extends Twig_Node
|
||||
$compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n");
|
||||
|
||||
// keep the values set in the inner context for variables defined in the outer context
|
||||
$compiler->write("\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));\n");
|
||||
$compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
|
||||
}
|
||||
\$_parent = \$context['_parent'];
|
||||
unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['item'], \$context['_parent'], \$context['loop']);
|
||||
\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));
|
||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
||||
EOF
|
||||
);
|
||||
|
||||
@@ -113,7 +113,7 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
||||
}
|
||||
\$_parent = \$context['_parent'];
|
||||
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
||||
\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));
|
||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
||||
EOF
|
||||
);
|
||||
|
||||
@@ -146,7 +146,7 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
||||
}
|
||||
\$_parent = \$context['_parent'];
|
||||
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
||||
\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));
|
||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
||||
EOF
|
||||
);
|
||||
|
||||
@@ -194,7 +194,7 @@ if (!\$context['_iterated']) {
|
||||
}
|
||||
\$_parent = \$context['_parent'];
|
||||
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
||||
\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));
|
||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
||||
EOF
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user