[Perf][SwiftParser] Scan the input on a lexer position rather than a cursor #3454
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.38) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.38 · 150 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.300
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3454"
general
weight: 0.35
nkcsgexi
A lexer cursor carries token-level state (the state stack, and the previous token's kind and keyword), but scanning bytes only ever needs the input position. Doing it on the cursor is what let
advance(if:)copy the whole cursor to look at one byte.This moves the byte-level work down to
Cursor.Position: reading a UTF-8 scalar, theis(offset:at:)andis(offset:notAt:)predicates,advance(matching:),advance(if:),advance(while:),advanceOverIdentifierContinuationCharacters,advanceToEndOfLineandtext(upTo:). The cursor keeps a forwarder for each, so no call site changes. The twenty places that save a cursor only to mark a spot in the input, for a diagnostic or to rewind after looking ahead, now save a position instead.advance(if:)also loses its hand-written ASCII fast path. It was working around the scalar read not being inlined; with the read marked@inline(__always), the position stays in registers and the ASCII case compiles to about what the fast path did by hand.No type changes size. Against main (911061a6775a6b1216504de882dc205c7b6de3f1) a parse is about 2–3% faster across four inputs (median of four alternated rounds: −1.8%, −2.3%, −3.1%, −1.3%).