Skip to content

Commit 4141df8

Browse files
committed
Rework the Twig files parsing
Every bundle file was parsed twice (for !@Bundle + @Bundle namespaces) + Passing all the paths to a single Finder allow it to not parse the same folder twice
1 parent 836ad06 commit 4141df8

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/Icons/src/Twig/IconFinder.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,13 @@ public function icons(): array
5454
*/
5555
private function files(LoaderInterface $loader): iterable
5656
{
57-
$files = [];
58-
5957
if ($loader instanceof FilesystemLoader) {
58+
$paths = [];
6059
foreach ($loader->getNamespaces() as $namespace) {
61-
foreach ($loader->getPaths($namespace) as $path) {
62-
foreach ((new Finder())->files()->in($path)->name('*.twig') as $file) {
63-
$file = (string) $file;
64-
if (!\in_array($file, $files, true)) {
65-
yield $file;
66-
}
67-
68-
$files[] = $file;
69-
}
70-
}
60+
$paths = [...$paths, ...$loader->getPaths($namespace)];
61+
}
62+
foreach ((new Finder())->files()->in($paths)->name('*.twig') as $file) {
63+
yield (string)$file;
7164
}
7265
}
7366

0 commit comments

Comments
 (0)