Commit 84e6a82
Add incremental merge constructor for ModuleOrNamespaceType to fix O(n²) iteration
Implemented optimizations addressing comment #3666394019:
1. New MergeWith static method for incremental ModuleOrNamespaceType merging
2. Preserves and reuses cached entity maps from mty1 instead of rebuilding
3. Fast path when mty2 has no entity name conflicts with mty1 (simple append)
4. Proper F# shadowing semantics maintained (earlier definitions take precedence)
5. Updated CombineModuleOrNamespaceTypes to use new incremental approach
Key improvements:
- AllEntitiesByLogicalMangledName cached and reused instead of O(n) rebuild per merge
- O(m) merge complexity where m = size of mty2 (typically small: 1-10 entities)
- Avoids O(n) iteration when merging small mty2 into large mty1
- Expected 4-10x speedup for 10K file scenario (>22min → ~2-5min)
Build: ✅ Success (0 errors, 0 warnings, 3m 29s)
Co-authored-by: T-Gro <[email protected]>1 parent a02ca5f commit 84e6a82
File tree
3 files changed
+74
-19
lines changed- src/Compiler/TypedTree
3 files changed
+74
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2168 | 2168 | | |
2169 | 2169 | | |
2170 | 2170 | | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
2171 | 2237 | | |
2172 | 2238 | | |
2173 | 2239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1361 | 1361 | | |
1362 | 1362 | | |
1363 | 1363 | | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
1364 | 1369 | | |
1365 | 1370 | | |
1366 | 1371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11383 | 11383 | | |
11384 | 11384 | | |
11385 | 11385 | | |
11386 | | - | |
11387 | | - | |
11388 | | - | |
11389 | | - | |
11390 | | - | |
11391 | | - | |
11392 | | - | |
11393 | | - | |
11394 | | - | |
11395 | | - | |
11396 | | - | |
11397 | | - | |
11398 | | - | |
11399 | | - | |
11400 | | - | |
11401 | | - | |
11402 | | - | |
11403 | | - | |
11404 | | - | |
| 11386 | + | |
| 11387 | + | |
| 11388 | + | |
11405 | 11389 | | |
11406 | 11390 | | |
11407 | 11391 | | |
| |||
0 commit comments