Commit 9cc7a05
committed
perf(compat-eslint): drop two intermediate-state anti-patterns
Two micro-fixes following the CPA-inline / no-visitor-mode cleanups:
1. `getAncestors` (lazy-source-code.ts) used `unshift` inside the
parent walk — O(n²) per call. Switch to `push` + `reverse` for
linear time. Visible to any rule that calls `context.getAncestors()`
on a deep node.
2. `getImplicitGlobals` (ts-scope-manager.ts) built a
`Map<string, { v, firstWrite }>` to dedupe by name, then collapsed
it via `Array.from(byName.values()).map(x => x.v)` — `firstWrite`
was never read after assignment. Replace with `Set<string>` for
dedupe + an `out: TsVariable[]` collected directly. Drops the
value-object wrapper, the Map-of-objects allocation, and the
`Array.from + map` collapse.
Surfaced while sweeping for CPA-style intermediate-buffer waste.1 parent 75ae2ef commit 9cc7a05
2 files changed
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
| 616 | + | |
616 | 617 | | |
617 | 618 | | |
618 | 619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1230 | 1230 | | |
1231 | 1231 | | |
1232 | 1232 | | |
1233 | | - | |
| 1233 | + | |
| 1234 | + | |
1234 | 1235 | | |
1235 | 1236 | | |
1236 | 1237 | | |
1237 | | - | |
| 1238 | + | |
| 1239 | + | |
1238 | 1240 | | |
1239 | 1241 | | |
1240 | 1242 | | |
| |||
1244 | 1246 | | |
1245 | 1247 | | |
1246 | 1248 | | |
1247 | | - | |
| 1249 | + | |
1248 | 1250 | | |
1249 | | - | |
| 1251 | + | |
1250 | 1252 | | |
1251 | 1253 | | |
1252 | 1254 | | |
| |||
0 commit comments