minor #1389 Move method so it's only called when necessary (Tobion)

This PR was merged into the 1.15-dev branch.

Discussion
----------

Move method so it's only called when necessary

Small performance improvement for getAttribute

Commits
-------

a28e0f1 Move method so it's only called when necessary
This commit is contained in:
Fabien Potencier
2014-04-23 22:31:20 +02:00
+2 -2
View File
@@ -402,8 +402,6 @@ abstract class Twig_Template implements Twig_TemplateInterface
throw new Twig_Error_Runtime(sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
}
$class = get_class($object);
// object property
if (Twig_Template::METHOD_CALL !== $type) {
if (isset($object->$item) || array_key_exists((string) $item, $object)) {
@@ -419,6 +417,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
}
}
$class = get_class($object);
// object method
if (!isset(self::$cache[$class]['methods'])) {
self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object)));