Skip to content

Commit fd360d8

Browse files
committed
Performance: Move existing path filter until after we know it's a valid
...prefix. This caused severe performance issues in long running processes.
1 parent 557fca8 commit fd360d8

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/Adapter/Composer/ComposerClassToFile.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ private function getFileCandidates(ClassName $className, array $prefixes)
9898
$candidates = [];
9999

100100
foreach ($prefixes as $prefix => $paths) {
101+
102+
if (is_int($prefix)) {
103+
$prefix = '';
104+
}
105+
106+
if ($prefix && false === $className->beginsWith($prefix)) {
107+
continue;
108+
}
109+
110+
if (!isset($candidates[$prefix])) {
111+
$candidates[$prefix] = [];
112+
}
113+
101114
$paths = (array) $paths;
102115
$paths = array_map(function ($path) {
103116
if (!file_exists($path)) {
@@ -112,18 +125,6 @@ private function getFileCandidates(ClassName $className, array $prefixes)
112125
return realpath($path);
113126
}, $paths);
114127

115-
if (is_int($prefix)) {
116-
$prefix = '';
117-
}
118-
119-
if ($prefix && false === $className->beginsWith($prefix)) {
120-
continue;
121-
}
122-
123-
if (!isset($candidates[$prefix])) {
124-
$candidates[$prefix] = [];
125-
}
126-
127128
$candidates[$prefix] = array_merge($candidates[$prefix], $paths);
128129
}
129130

0 commit comments

Comments
 (0)