Commit 3c95d7f
committed
perf(expression): fast-path identifier characters and short-circuit keyword scans
Speed up expression parsing by skipping work that provably cannot match:
- Add an identifier/number-character fast path to the expression loop. Such a
character is never whitespace, never a terminator (no `shouldTerminate`
implementation matches a word character), and is not one of the switch's
cases, so it can short-circuit the termination checks and the switch dispatch
entirely and just advance the position.
- Bail out of the unary/binary operator keyword scans immediately when the
surrounding character cannot start or end a keyword (every keyword is
lowercase ASCII letters).
No behavior change: the full test suite passes and parser output is identical.1 parent 221d3b7 commit 3c95d7f
2 files changed
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
123 | 133 | | |
124 | 134 | | |
125 | 135 | | |
| |||
461 | 471 | | |
462 | 472 | | |
463 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
464 | 478 | | |
465 | 479 | | |
466 | 480 | | |
| |||
510 | 524 | | |
511 | 525 | | |
512 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
513 | 532 | | |
514 | 533 | | |
515 | 534 | | |
| |||
0 commit comments