Stop sub after the first match and reuse plain replacements #315
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 237 lines diff across 2 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.327
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #315"
general
weight: 0.35
g4lb
sub()found every match but replaced only the first. Now it finds only the first match. A replacement without&or\is also reused for each match. A call with no match does not read the replacement. The output does not change.| Case | Time | Bytes | Allocs |
|---|---|---|---|
|
BuiltinSub| 8.12 → 3.10 µs | 7548 → 2606 B | 106 → 30 ||
BuiltinSubAmpersand| 8.24 → 2.99 µs | 7548 → 2607 B | 106 → 30 ||
BuiltinGsub| 9.61 → 8.87 µs | 12125 → 11876 B | 147 → 102 ||
BuiltinGsubAmpersand| 9.60 → 9.51 µs | 12137 → 12122 B | 147 → 147 ||
BuiltinSubstr| 482 → 402 ns | 0 → 0 B | 0 → 0 ||
sub, first of many, long line | 49.6 → 33.5 µs | 119.3 → 111.1 KB | 68 → 58 ||
subwith&, first of many | 48.1 → 32.8 µs | 119.3 → 111.1 KB | 69 → 58 ||
sub, no match | 33.8 → 33.3 µs | 113.9 → 109.4 KB | 64 → 61 ||
gsub, plain | 48.6 → 48.3 µs | 119.3 → 119.3 KB | 68 → 68 ||
gsubwith&| 51.6 → 51.8 µs | 120.3 → 120.3 KB | 268 → 268 ||
gsub, short line | 32.8 → 32.8 µs | 108.9 → 108.9 KB | 59 → 59 ||
sub, no match, 4 KB replacement | 248 → 190 µs | 173.8 → 126.9 KB | 4064 → 1064 ||
gsub, no match, 4 KB replacement | 246 → 241 µs | 173.7 → 173.7 KB | 4064 → 4064 ||
sub, no match, short replacement | 239 → 182 µs | 169.7 → 122.8 KB | 4060 → 1060 ||
sub, 4 KB replacement | 8.06 → 1.96 ms | 25.2 → 4.8 MB | 14087 → 3071 ||
gsub, short replacement | 407 → 383 µs | 176.9 → 176.9 KB | 5055 → 5055 ||
gsub, 4 KB replacement | 16.27 → 16.25 ms | 55.1 → 55.1 MB | 24110 → 24110 ||
gsubwith&, many matches | 1.43 → 1.42 ms | 348.8 → 348.8 KB | 21050 → 21050 |No row was slower in all 3 code layouts (AMD EPYC 9V74, Go 1.27.4, 24 rounds).
BuiltinSubstrdoes not call the changed code. Its time moved by −17% to +17% with the code layout.go test -racepasses with a master build as-awk. Old and new output matched on 1M random inputs.