From 40f25a420c7907632bd28f46560cabe964dcfba9 Mon Sep 17 00:00:00 2001 From: nikic <+@ni-po.com> Date: Tue, 14 Dec 2010 18:49:35 +0100 Subject: [PATCH] improve filesystem loader cache and use '/' instead of DIRECTORY_SEPARATOR --- lib/Twig/Loader/Filesystem.php | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 98d9806..8ba22b2 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -103,6 +103,10 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface { // normalize name $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); + + if (isset($this->cache[$name])) { + return $this->cache[$name]; + } $parts = explode('/', $name); $level = 0; @@ -118,13 +122,9 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface } } - if (isset($this->cache[$name])) { - return $this->cache[$name]; - } - foreach ($this->paths as $path) { - if (file_exists($path.DIRECTORY_SEPARATOR.$name) && !is_dir($path.DIRECTORY_SEPARATOR.$name)) { - return $this->cache[$name] = $path.DIRECTORY_SEPARATOR.$name; + if (file_exists($path.'/'.$name) && !is_dir($path.'/'.$name)) { + return $this->cache[$name] = $path.'/'.$name; } } -- 1.7.2.5