This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Commit 7e918a1
committed
perf(tool/edit): use rolling rows instead of full matrix in levenshtein
BlockAnchorReplacer calls levenshtein() per line during fuzzy oldString
matching, and it was allocating a full (n+1)x(m+1) matrix (via nested
Array.from callbacks) on every call — unnecessary GC pressure on large
files, since only the final distance is needed, not a full matrix for
backtracking. Switched to two rolling 1D rows (O(min(n,m)) space instead of
O(n*m)).
Verified: existing edit tool suite (29/29 pass) plus a 20,000-case fuzz
comparison against the original implementation confirms byte-identical
output.
Ref anomalyco#47604. Note: that issue also reports the module-level `locks` Map in
edit.ts never evicting entries (slow memory leak over long sessions).
Deliberately not touched here — safely evicting a lock out from under a
potential concurrent holder needs more careful study than time allowed for
this pass; a rushed fix risks breaking the mutual-exclusion guarantee
entirely.1 parent b45c3ea commit 7e918a1
1 file changed
Lines changed: 13 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
229 | 234 | | |
230 | 235 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
234 | 239 | | |
235 | 240 | | |
| 241 | + | |
236 | 242 | | |
237 | 243 | | |
238 | | - | |
| 244 | + | |
239 | 245 | | |
| 246 | + | |
240 | 247 | | |
241 | | - | |
| 248 | + | |
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
| |||
0 commit comments