Skip to content

Commit

Permalink
better stackLoader cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kokspflanze committed Nov 20, 2019
1 parent 8b18123 commit db44458
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Twig/StackLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ protected function findTemplate(string $name, bool $throw = true): ?string
// normalize name
$name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));

// Ensure we have the expected file extension
$defaultSuffix = $this->getDefaultSuffix();
if (pathinfo($name, PATHINFO_EXTENSION) != $defaultSuffix) {
$name .= '.' . $defaultSuffix;
}

if (isset($this->cache[$name])) {
return $this->cache[$name];
}
Expand All @@ -78,12 +84,6 @@ protected function findTemplate(string $name, bool $throw = true): ?string
throw new Error\LoaderError($this->errorCache[$name]);
}

// Ensure we have the expected file extension
$defaultSuffix = $this->getDefaultSuffix();
if (pathinfo($name, PATHINFO_EXTENSION) != $defaultSuffix) {
$name .= '.' . $defaultSuffix;
}

$this->validateName($name);

$namespace = '__main__';
Expand Down

0 comments on commit db44458

Please sign in to comment.