mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
Merge branch '2.x' into 3.x
* 2.x: Remove unneeded coments Optimize Environment::resolveTemplate() to be much faster when template overrides do not exist
This commit is contained in:
+12
-3
@@ -433,11 +433,20 @@ class Environment
|
||||
return $this->load($names);
|
||||
}
|
||||
|
||||
$count = \count($names);
|
||||
foreach ($names as $name) {
|
||||
try {
|
||||
return $this->load($name);
|
||||
} catch (LoaderError $e) {
|
||||
if ($name instanceof Template) {
|
||||
return $name;
|
||||
}
|
||||
if ($name instanceof TemplateWrapper) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (1 !== $count && !$this->getLoader()->exists($name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $this->load($name);
|
||||
}
|
||||
|
||||
throw new LoaderError(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
|
||||
|
||||
Reference in New Issue
Block a user