Commit 2ca011b
perf: bulk-append unescaped character runs in JSON parseString
Replace per-character StringBuilder.Append(char) calls with
StringBuilder.Append(string, start, length) for consecutive runs of
unescaped characters in the JSON string parser.
For strings with no escape sequences (the common case in real-world
JSON), this reduces the number of Append calls from O(n) to O(1),
which should meaningfully speed up JsonValue.Parse on workloads
with many string values.
The approach mirrors what JsonStringEncodeTo already does for
serialisation: track a chunk start position and flush accumulated
characters as a bulk substring when an escape or closing quote is hit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent bb36ab3 commit 2ca011b
2 files changed
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
318 | 327 | | |
319 | 328 | | |
| 329 | + | |
320 | 330 | | |
321 | 331 | | |
322 | 332 | | |
| |||
371 | 381 | | |
372 | 382 | | |
373 | 383 | | |
| 384 | + | |
374 | 385 | | |
375 | | - | |
376 | 386 | | |
377 | 387 | | |
| 388 | + | |
| 389 | + | |
378 | 390 | | |
379 | 391 | | |
380 | 392 | | |
| |||
0 commit comments