mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 03:46:39 +00:00
made a small optimization to for loop when no else clause exists
git-svn-id: http://svn.twig-project.org/trunk@32 93ef8e89-cb99-4229-a87c-7fa0fa45744b
This commit is contained in:
+15
-3
@@ -51,16 +51,28 @@ class Twig_Node_For extends Twig_Node implements Twig_NodeListInterface
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->pushContext()
|
||||
->write("\$context['_iterated'] = false;\n")
|
||||
;
|
||||
|
||||
if (!is_null($this->else))
|
||||
{
|
||||
$compiler->write("\$context['_iterated'] = false;\n");
|
||||
}
|
||||
|
||||
$compiler
|
||||
->write('foreach (twig_iterate($context, ')
|
||||
->subcompile($this->seq)
|
||||
->raw(") as \$iterator)\n")
|
||||
->write("{\n")
|
||||
->indent()
|
||||
->write("\$context['_iterated'] = true;\n")
|
||||
->write('twig_set_loop_context($context, $iterator, ');
|
||||
;
|
||||
|
||||
if (!is_null($this->else))
|
||||
{
|
||||
$compiler->write("\$context['_iterated'] = true;\n");
|
||||
}
|
||||
|
||||
$compiler->write('twig_set_loop_context($context, $iterator, ');
|
||||
|
||||
if ($this->isMultitarget)
|
||||
{
|
||||
$compiler->raw('array(');
|
||||
|
||||
Reference in New Issue
Block a user