Repository navigation
feat: optimize 'when' directive for fixed templates - #7783
Merged
Merged
Conversation
John Kreitlow (radium-v)
requested review from
Chris Holt (chrisdholt) and
Jane Chu (janechu)
as code owners
October 27, 2026 22:05
Jane Chu (janechu)
approved these changes
Oct 28, 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.
Pull Request
📖 Description
Reduce
whenoverhead when both branches are fixed templates. The new path avoids creating and calling wrapper functions, and selects the result once when the condition is constant.Template bindings still run only for the selected branch. A false condition without an else template still returns
null. Includes regression tests and updated API docs and size reports.👩💻 Reviewer Notes
Chromium microbenchmarks showed 25–29% lower construction time and 3–9% lower evaluation time for dynamic conditions with fixed templates. These measurements exclude DOM rendering.
The focused
whenexport grows from 731 to 781 bytes gzipped.📑 Test Plan
whensuite passed.✅ Checklist
General
$ npm run changeAgents