Repository navigation
Commit 67f72d8
Keep empty constant arrays out of the oversized merge in
- optimizeConstantArrays() generalizes every non-empty constant array of an
oversized union to `non-empty-array<K, V>&oversized-array` and, when every
member got generalized, merges them into a single oversized array. An
`array{}` member is left alone by the generalization, so it set
$eachIsOversized to false and the merge was skipped. The generalized
members were then returned as separate union members.
- Since e606ca2 (unions of constant arrays with many keys no longer
degrade early), fetching an unknown offset of a big constant map, where
some entries are `[]` (bug-12671.php bench), hit this path. The union then
compared hundreds of generalized arrays pairwise. Their item types are
large unions of `list{...}&oversized-array`, so every comparison is itself
a union-vs-union check, which made the fetch quadratic (bench 0.3s -> 26s).
- Set empty constant arrays aside before generalizing, merge the remaining
members as before, and put the empty arrays back next to the result. A
union with an `array{}` member now gives `array{}` plus exactly what the
same union without it gives.
- Ported the same change to the native mirror in
turbo-ext/src/TypeCombinator.cpp.
- Probed the other paths that feed optimizeConstantArrays() (the
general-array branch of processArrayTypes() reuses the same function, so it
is covered). The inner value traversal already left empty arrays alone.
- Non-constant array members also prevent the merge. That is intended
(their item types are not generalized), so it is unchanged.TypeCombinator::optimizeConstantArrays()
1 parent 1f8dd0a commit 67f72d8
3 files changed
Lines changed: 243 additions & 8 deletions
File tree
- src/Type
- tests/PHPStan/Analyser/nsrt
- turbo-ext/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1207 | 1207 | | |
1208 | 1208 | | |
1209 | 1209 | | |
| 1210 | + | |
1210 | 1211 | | |
1211 | 1212 | | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1212 | 1218 | | |
1213 | 1219 | | |
1214 | 1220 | | |
| |||
1290 | 1296 | | |
1291 | 1297 | | |
1292 | 1298 | | |
1293 | | - | |
| 1299 | + | |
1294 | 1300 | | |
1295 | 1301 | | |
1296 | 1302 | | |
| |||
1317 | 1323 | | |
1318 | 1324 | | |
1319 | 1325 | | |
1320 | | - | |
| 1326 | + | |
1321 | 1327 | | |
1322 | 1328 | | |
1323 | | - | |
| 1329 | + | |
1324 | 1330 | | |
1325 | 1331 | | |
1326 | 1332 | | |
| |||
| 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 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2184 | 2184 | | |
2185 | 2185 | | |
2186 | 2186 | | |
| 2187 | + | |
2187 | 2188 | | |
2188 | 2189 | | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
2189 | 2201 | | |
2190 | 2202 | | |
2191 | 2203 | | |
| |||
2200 | 2212 | | |
2201 | 2213 | | |
2202 | 2214 | | |
2203 | | - | |
| 2215 | + | |
2204 | 2216 | | |
2205 | 2217 | | |
2206 | 2218 | | |
| |||
2236 | 2248 | | |
2237 | 2249 | | |
2238 | 2250 | | |
2239 | | - | |
2240 | | - | |
2241 | | - | |
| 2251 | + | |
| 2252 | + | |
2242 | 2253 | | |
2243 | 2254 | | |
2244 | | - | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
2245 | 2259 | | |
2246 | 2260 | | |
2247 | 2261 | | |
| |||
0 commit comments