Render switch discriminant once per group; drop dead inner scope#253
Open
AaronWebster wants to merge 1 commit into
Open
Render switch discriminant once per group; drop dead inner scope#253AaronWebster wants to merge 1 commit into
AaronWebster wants to merge 1 commit into
Conversation
The optimized Ok() switch-block code in _generate_optimized_ok_method_body
was rendering each switch group's discriminant twice: once unscoped at
grouping time to build the SWITCH: key, and again with the active
ExpressionScope at emit time. Render it once with the scope and reuse
the result. The result is stable for equivalent discriminants because
ExpressionScope.add dedupes by inner rendered form, so it still works
as a grouping key.
The ok_method_switch_block template's \${inner_scope_definitions}
placeholder was unused — the inner ExpressionScope it referenced had
nothing added to it. Removed both, which also drops the blank line
each switch block carried in the goldens.
No behavioral change; purely compile-time cleanup. Golden churn
limited to the blank-line removal in four files (one line per existing
switch block).
This was referenced May 20, 2026
robrussell
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The optimized
Ok()switch-block code in_generate_optimized_ok_method_bodywas rendering each switch group's discriminant twice — once unscoped at grouping time to build the SWITCH key, and again with the activeExpressionScopeat emit time. Render it once with the scope and reuse the result. BecauseExpressionScope.adddedupes by inner rendered form, the result is stable for equivalent discriminants and still works as a grouping key.The
ok_method_switch_blocktemplate's${inner_scope_definitions}placeholder was unused — the innerExpressionScopeit referenced had nothing added to it. Removed both, which also drops the blank line each switch block was carrying in the goldens.Pure compile-time cleanup; no behavioral change.
Size impact
Foundation for #254 / #256 / #257 / #258 / #259 (see those for the wins this enables).