From: nikic <+@ni-po.com> Date: Tue, 14 Dec 2010 17:49:35 +0000 (+0100) Subject: improve filesystem loader cache and use '/' instead of DIRECTORY_SEPARATOR X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=40f25a420c7907632bd28f46560cabe964dcfba9;p=konrad%2Ftwig.git improve filesystem loader cache and use '/' instead of DIRECTORY_SEPARATOR --- 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; } }