Repository navigation
Avoid allocating a bool for cached computed names - #65067
Merged
Merged
Conversation
Computed name caching needs three states, but a bool pointer adds a separate allocation and another pointer for the GC to scan. Use the existing tristate representation to avoid that overhead.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the computed-property-name cache change.
No open issues 🎉
What changed in this PR
This PR removes a boolean allocation from the compiler’s computed-property-name cache by replacing a boolean pointer with core.Tristate.
Changes:
- Represent unknown, present, and absent cached-name states with
core.Tristate. - Update cache reads and writes to use tristate checks and conversion.
| File | Description |
|---|---|
tsc/internal/checker/types.go |
Changes the cached hasName field from *bool to core.Tristate. |
tsc/internal/checker/checker.go |
Uses tristate helpers when reading and storing computed-name results. |
Review effort: Balanced
Anders Hejlsberg (ahejlsberg)
approved these changes
Oct 30, 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.
I found this during some unrelated work. There's no reason to allocate a bool here and use a pointer when a tristate suffices.