← Back to Pull requests

[Perf][SwiftParser] Scan the input on a lexer position rather than a cursor #3454

Closed
unknown closed this pull request without merging on Oct 02, 2026 03:09 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 18:41 UTC
Author

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, the is(offset:at:) and is(offset:notAt:) predicates, advance(matching:), advance(if:), advance(while:), advanceOverIdentifierContinuationCharacters, advanceToEndOfLine and text(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%).

Diff: 150 lines (+112 / -38) across 1 files Reviewer: nkcsgexi Review duration: 508m
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
0.38
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38% (MEDIUM) · Higher = larger blast radius
38%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15% · Safe to merge
15%