Repository navigation
Commit 1447c34
committed
Merge two single-key arrays once when unioning them
The single-key merge in reduceArrays() added for phpstan/phpstan#14462
unioned the two values to decide whether to merge, then mergeWith()
unioned them again, and the keys-superset merge of the same pair below
did it a third time. With arrays nested in each other (`$x = [$x]` in
nested loops) every union repeats the work for each level, so the
analysis became exponential in the nesting: three nested while loops
take 44 seconds instead of 0.2, four do not finish.
mergeWith() is now called once, its merged value decides the question,
and the keys-superset branch reuses it.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1c574-f264-7659-8779-5e71ca99b89b1 parent 3b785fd commit 1447c34
3 files changed
Lines changed: 68 additions & 22 deletions
File tree
- src/Type
- tests/bench/data
- turbo-ext/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2003 | 2003 | | |
2004 | 2004 | | |
2005 | 2005 | | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
2006 | 2012 | | |
2007 | 2013 | | |
2008 | 2014 | | |
2009 | 2015 | | |
2010 | 2016 | | |
2011 | 2017 | | |
2012 | | - | |
2013 | | - | |
2014 | | - | |
2015 | | - | |
2016 | | - | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
2017 | 2021 | | |
2018 | 2022 | | |
2019 | 2023 | | |
| |||
2039 | 2043 | | |
2040 | 2044 | | |
2041 | 2045 | | |
2042 | | - | |
| 2046 | + | |
2043 | 2047 | | |
2044 | 2048 | | |
2045 | 2049 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2967 | 2967 | | |
2968 | 2968 | | |
2969 | 2969 | | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
2970 | 2978 | | |
2971 | 2979 | | |
2972 | 2980 | | |
2973 | 2981 | | |
2974 | 2982 | | |
2975 | 2983 | | |
2976 | | - | |
2977 | | - | |
2978 | | - | |
| 2984 | + | |
2979 | 2985 | | |
2980 | 2986 | | |
2981 | 2987 | | |
| |||
3379 | 3385 | | |
3380 | 3386 | | |
3381 | 3387 | | |
3382 | | - | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
3383 | 3395 | | |
3384 | 3396 | | |
3385 | 3397 | | |
3386 | 3398 | | |
3387 | | - | |
3388 | | - | |
3389 | | - | |
3390 | | - | |
3391 | | - | |
3392 | | - | |
3393 | | - | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
3394 | 3406 | | |
3395 | 3407 | | |
3396 | 3408 | | |
3397 | | - | |
3398 | | - | |
3399 | | - | |
3400 | | - | |
| 3409 | + | |
| 3410 | + | |
3401 | 3411 | | |
3402 | 3412 | | |
3403 | 3413 | | |
| |||
3420 | 3430 | | |
3421 | 3431 | | |
3422 | 3432 | | |
3423 | | - | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
3424 | 3438 | | |
3425 | 3439 | | |
3426 | 3440 | | |
| |||
0 commit comments