Commit b41ee24
committed
parser: splice deletion-shaped surgery in place (#45)
Node surgery only spliced in place when the new kid count equalled the removed
count; any edit that SHRANK the count (deleting a list element, a member, a union
arm) fell to the end-allocation branch — a full row copy to the arena tail. That
path is correct but relocates, growing the arena.
A shrink (f < removed) FITS the original kid range: the suffix shifts LEFT, which
is an overlap-safe forward copy, so target csD in place and add no rows. The
per-kid transforms (prefix-rel normalize, new kids, suffix copy, end-relative
boundary remap) are exactly the proven end-allocation ones — only the destination
changes — so it reuses that code with ks = csD. Grows (f > removed) still relocate.
exhaustive-edits asserts the in-place-shrink branch actually fires (8 splices at
≤4 chars, 60 at ≤5) and that all 3.2M edited trees stay byte-identical to fresh;
__arenaStats exposes the counter.1 parent ba295f1 commit b41ee24
2 files changed
Lines changed: 19 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1501 | 1501 | | |
1502 | 1502 | | |
1503 | 1503 | | |
| 1504 | + | |
1504 | 1505 | | |
1505 | 1506 | | |
1506 | 1507 | | |
| |||
3259 | 3260 | | |
3260 | 3261 | | |
3261 | 3262 | | |
3262 | | - | |
3263 | | - | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
3264 | 3272 | | |
3265 | 3273 | | |
3266 | 3274 | | |
| |||
3288 | 3296 | | |
3289 | 3297 | | |
3290 | 3298 | | |
3291 | | - | |
| 3299 | + | |
3292 | 3300 | | |
3293 | 3301 | | |
3294 | 3302 | | |
| |||
3999 | 4007 | | |
4000 | 4008 | | |
4001 | 4009 | | |
4002 | | - | |
| 4010 | + | |
4003 | 4011 | | |
4004 | 4012 | | |
4005 | 4013 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
| 78 | + | |
74 | 79 | | |
0 commit comments