minor #2649 Make a small performance improvement (fabpot)

This PR was merged into the 2.x branch.

Discussion
----------

Make a small performance improvement

And it also fixes some potential subtle bugs.

Commits
-------

27f905ed made a small performance improvement
This commit is contained in:
Fabien Potencier
2018-03-04 10:01:43 -08:00
2 changed files with 3 additions and 5 deletions
+2
View File
@@ -160,6 +160,8 @@ final class Twig_ExtensionSet
throw new LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $class));
}
// For BC/FC with namespaced aliases
$class = (new ReflectionClass($class))->name;
$this->extensions[$class] = $extension;
}
+1 -5
View File
@@ -41,11 +41,7 @@ abstract class Twig_Template
public function __construct(Twig_Environment $env)
{
$this->env = $env;
foreach ($env->getExtensions() as $extension) {
// For BC/FC with namespaced aliases
$class = (new ReflectionClass(get_class($extension)))->name;
$this->extensions[ltrim($class, '\\')] = $extension;
}
$this->extensions = $env->getExtensions();
}
/**