Repository navigation
Conversation
Changelog💅 Polish
Semantic Diff1 commit · Full page Find duplicate pattern variables in a set of the bound names4bae89d · cknitt + Claude · Nov 07, 2026, 10:07 UTC
The names are kept in a set next to the list of variables, in one value, so that resetting the pattern and the save and restore around or-patterns carry both. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9260 +/- ##
==========================================
- Coverage 81.74% 81.74% -0.01%
==========================================
Files 457 457
Lines 65713 65712 -1
==========================================
- Hits 53715 53714 -1
Misses 11998 11998
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9260 |
Why:
Each new pattern variable was compared with every variable the
pattern had bound so far, and a `let rec … and …` group is one
pattern, so n bindings cost O(n²) string comparisons: 16,000 bindings
took 2.7 s. They now take 2.0 s.
The names are kept in a set next to the list of variables, in one value,
so that resetting the pattern and the save and restore around or-patterns
carry both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gK1dcjbe97yY1wRMgs
Signed-off-by: Christoph Knittel <ck@cca.io>
7d5740b to
4bae89d
Compare
🎉 Compiler benchmarksAllocated wordsIn total: 456,989,425 → 457,158,125 (+0.04%).
InstructionsIn total: 10,226,962,259 → 10,126,222,706 (-0.99%). 🎉 Improvement: 1 benchmark executes more than 1% fewer instructions.
Pull request 4bae89d compared with base bf35764 in this run. |
Part of #9256 (duplicate check of pattern variables).
Typecore.enter_variablecompared each new variable with all variables of the pattern so far, and alet rec … and …group is one pattern. The bound names are now kept in a set next to the list. Both live in one value of the request state, so resetting the pattern,add_pattern_variablesand the save and restore around or-patterns carry the set along without extra code.Measured with
bscon linux-arm64, alet recgroup of n bindings (allocations were already linear; this saves string comparisons):New tests:
multiply_bound_variable_let_rec(a duplicate in alet recgroup),multiply_bound_variable_or_pattern(an or-pattern binding the same name on both sides is accepted, then a real duplicate is reported) andmultiply_bound_variable_alias(Some(a) as a).🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gK1dcjbe97yY1wRMgs