Commit 657652f
committed
perf: real LRU eviction in git diff cache + hoist newline regex
The prior gitDiffAccessOrder array was append-on-write, so it tracked
insertion order, not recency — a real LRU needs touch-on-read. And
shift() on eviction was O(n). Replace with a single Map that relies
on insertion-order iteration: delete + re-set on read marks recent,
keys().next() + delete on eviction is O(1).
Also hoist the /\n/g regex in fs.ts stringify() to module scope;
previously it was rebuilt on every JSON write.1 parent d124401 commit 657652f
2 files changed
+26
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
450 | 453 | | |
451 | 454 | | |
452 | 455 | | |
453 | | - | |
| 456 | + | |
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
159 | 162 | | |
160 | | - | |
161 | 163 | | |
162 | 164 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
| 182 | + | |
173 | 183 | | |
174 | 184 | | |
175 | 185 | | |
| |||
317 | 327 | | |
318 | 328 | | |
319 | 329 | | |
320 | | - | |
| 330 | + | |
321 | 331 | | |
322 | 332 | | |
323 | 333 | | |
| |||
349 | 359 | | |
350 | 360 | | |
351 | 361 | | |
352 | | - | |
353 | | - | |
354 | | - | |
| 362 | + | |
355 | 363 | | |
356 | 364 | | |
357 | 365 | | |
| |||
373 | 381 | | |
374 | 382 | | |
375 | 383 | | |
376 | | - | |
| 384 | + | |
377 | 385 | | |
378 | 386 | | |
379 | 387 | | |
| |||
405 | 413 | | |
406 | 414 | | |
407 | 415 | | |
408 | | - | |
409 | | - | |
410 | | - | |
| 416 | + | |
411 | 417 | | |
412 | 418 | | |
413 | 419 | | |
| |||
0 commit comments