From b83c7773106bb55814a676143c8657b559318f6b Mon Sep 17 00:00:00 2001 From: SimonHeimberg Date: Sat, 28 Jan 2017 00:18:06 +0100 Subject: [PATCH] Improved speed of DirectoryResource --- .../Component/Config/Resource/DirectoryResource.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index 120ab43d1937a..6ef58fc982e05 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -74,7 +74,9 @@ public function isFresh($timestamp) return false; } - $newestMTime = filemtime($this->resource); + if (filemtime($this->resource) < $timestamp) { + return true; + } foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) { // if regex filtering is enabled only check matching files if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) { @@ -87,10 +89,12 @@ public function isFresh($timestamp) continue; } - $newestMTime = max($file->getMTime(), $newestMTime); + if ($file->getMTime() < $timestamp) { + return true + } } - return $newestMTime < $timestamp; + return false; } public function serialize()