Optimize initGlobals to do only one merge call
authorJordi Boggiano <j.boggiano@seld.be>
Sat, 4 May 2013 20:18:16 +0000 (22:18 +0200)
committerJordi Boggiano <j.boggiano@seld.be>
Sat, 4 May 2013 20:18:16 +0000 (22:18 +0200)
lib/Twig/Environment.php

index 54df5be..eafe02a 100644 (file)
@@ -1103,11 +1103,13 @@ class Twig_Environment
             if (!is_array($extGlob)) {
                 throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
             }
-            
-            $globals = array_merge($globals, $extGlob);
+
+            $globals[] = $extGlob;
         }
 
-        return array_merge($globals, $this->staging->getGlobals());
+        $globals[] = $this->staging->getGlobals();
+
+        return call_user_func_array('array_merge', $globals);
     }
 
     protected function initExtensions()