8000 [Config] Improve GlobResource performance · symfony/symfony@172b1f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 172b1f7

Browse files
committed
[Config] Improve GlobResource performance
1 parent eece9de commit 172b1f7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function __wakeup(): void
9797

9898
public function getIterator(): \Traversable
9999
{
100-
if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {
100+
if ((!$this->recursive && '' === $this->pattern) || !file_exists($this->prefix)) {
101101
return;
102102
}
103103

@@ -148,7 +148,7 @@ public function getIterator(): \Traversable
148148
} while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath));
149149
}
150150

151-
if (is_file($path) && (null === $regex || preg_match($regex, substr(str_replace('\\', '/', $path), $prefixLen)))) {
151+
if ((null === $regex || preg_match($regex, substr(str_replace('\\', '/', $path), $prefixLen))) && is_file($path)) {
152152
yield $path => new \SplFileInfo($path);
153153
}
154154
if (!is_dir($path)) {
@@ -165,7 +165,7 @@ public function getIterator(): \Traversable
165165
new \RecursiveCallbackFilterIterator(
166166
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
167167
fn (\SplFileInfo $file, $path) => !isset($this->excludedPrefixes[$path = str_replace('\\', '/', $path)])
168-
&& (null === $regex || $file->isDir() || preg_match($regex, substr($path, $prefixLen)))
168+
&& (null === $regex || preg_match($regex, substr($path, $prefixLen)) || $file->isDir())
169169
&& '.' !== $file->getBasename()[0]
170170
),
171171
\RecursiveIteratorIterator::LEAVES_ONLY

0 commit comments

Comments
 (0)
0