Commit e449e70
committed
Improve performance of Box::collectRemainingFiles()
The `->notPath()` filter of Symfony Finder is either accepting a “literal path”
or a regular expression and converts each literal path to a regular expression
and then filters the file stream by applying each regex individually. This
leads to O(bufferedFileNames^2) calls to `preg_match()`, well over 20 million
for PHPStan.
Fix this by performing a simple `in_array()` check on the buffered files. This
brings down the time to compile PHPStan from 2:35 to 0:25 on my machine.
I have verified that the resulting PHPStan Phar hash is identical before and
after this change.
Fixes #1551.1 parent db022b8 commit e449e70
1 file changed
+10
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | | - | |
53 | | - | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
222 | 221 | | |
223 | 222 | | |
224 | 223 | | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
237 | 233 | | |
238 | 234 | | |
239 | 235 | | |
| |||
0 commit comments