perf: assign variadic and array chainable methods directly #398
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 234 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.327
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #398"
general
weight: 0.35
g4lb
variadicandarrayChainablenow set their methods directly, not throughObject.assignwith a new object.P.array(...)is then cheaper to create, so inline patterns are faster. The results do not change.Built
dist/index.js, ms per loop over mixed inputs, 20 rounds, Mann-Whitney test (Node 24, Apple M2 Max):| Benchmark | Before | After | Change |
|---|---:|---:|---:|
| Tuples with
...P.array(), 7 branches | 2.26 | 1.63 | −28% || 3 inline
isMatchingpatterns, one withP.array| 0.47 | 0.34 | −27% || Nested objects with
[1, ...P.array(P.number)]| 0.61 | 0.46 | −25% || Selections with
P.array(P.select())| 2.57 | 2.12 | −18% || Event reducer, 14 inline branches | 2.58 | 2.20 | −15% |
Other benchmarks did not change. Gzip size: +16 bytes.
Checks:
tsc --noEmit, the build andjestpass.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Assigns
Symbol.iterator,optional, andselectdirectly on the pattern object instead of building a new object withObject.assign. CreatingP.array(...)patterns is now cheaper, which speeds up inline patterns by 15–28% with identical behavior.<sup>Written for commit 240a021c7b8771373b8dbbfd4b7164382171dc7b. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/gvergnaud/ts-pattern/pull/398?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->