Commit c4eb2bc
authored
perf(parser): skip the pre-pass line scan when the source has no "]:" (#517)
A reference definition's label must be closed by ] immediately followed
by : ([label]:), and a footnote opener requires the same ([^label]:). A
] and : split across a line break never parses as a definition (the
joined chunk keeps the newline between them), so the absence of a
contiguous "]:" proves the whole line scan would collect nothing.
Gate build_prepass on one memmem sweep for that needle; typical
link-only documents skip the scan entirely.
1 MB JS-harness sample (no "]:"): pipeline p50 14.92 -> 14.40 ms
(-3.5%), build_prepass self 0.45 -> 0.03 ms/iter. Documents containing
"]:" (e.g. types.md) pay one extra memmem sweep and are unchanged.
Three new edge tests pin the necessary-condition reasoning (split
"]\n:" is not a definition, escaped brackets keep the real "]:"
visible to the gate, link-only documents still parse). Differential
fuzz vs the pre-fusion baseline: 232 cases, zero mismatches.1 parent 3961189 commit c4eb2bc
2 files changed
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
0 commit comments