From 448106fa040a833b290868acbcb57a9c7738cd7f Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Fri, 29 Apr 2011 01:34:13 -0700 Subject: [PATCH] DRY optimization --- lib/Twig/Node/Module.php | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 83bee45..a3cc0be 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -129,7 +129,8 @@ class Twig_Node_Module extends Twig_Node ->write("parent::__construct(\$env);\n\n") ; - if (count($this->getNode('traits'))) { + $countTraits = count($this->getNode('traits')); + if ($countTraits) { // traits foreach ($this->getNode('traits') as $i => $trait) { $this->compileLoadTemplate($compiler, $trait->getNode('template'), sprintf('$_trait_%s', $i)); @@ -163,7 +164,7 @@ class Twig_Node_Module extends Twig_Node ->indent() ; - for ($i = 0, $count = count($this->getNode('traits')); $i < $count; $i++) { + for ($i = 0; $i < $countTraits; $i++) { $compiler ->write(sprintf("\$_trait_%s_blocks,\n", $i)) ; @@ -189,7 +190,7 @@ class Twig_Node_Module extends Twig_Node ; } - if (count($this->getNode('traits'))) { + if ($countTraits) { $compiler ->outdent() ->write(")\n") -- 1.7.2.5