Repository navigation
Reuse contextual type from const-context checks - #65805
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
checkObjectLiteralMethod previously computed the contextual type twice
when checking isConstContext. Return the already-computed contextual
type from isConstContextEx and add early-outs in isConstTypeVariable.
benchstat (-pgo=off, parent vs commit, n=6):
goos: linux
goarch: amd64
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/vscode 6.165 ± 2% 6.134 ± 1% ~ (p=0.394 n=6)
Tsc/mui-docs 3.661 ± 3% 3.665 ± 2% ~ (p=0.818 n=6)
geomean 4.751 4.742 -0.20%
│ old │ new │
│ B-rss │ B-rss vs base │
Tsc/vscode 4.575Gi ± 2% 4.682Gi ± 3% ~ (p=0.485 n=6)
Tsc/mui-docs 2.114Gi ± 6% 2.177Gi ± 9% ~ (p=0.240 n=6)
geomean 3.110Gi 3.193Gi +2.67%
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the contextual-type reuse and const-check optimizations.
No open issues 🎉
What changed in this PR
Optimizes the compiler’s const-context checks by reusing contextual types and avoiding unnecessary type traversal.
Changes:
- Adds
isConstContextExto return the contextual type alongside the const-context result. - Reuses that type when checking expressions in mutable locations.
- Adds early exits in
isConstTypeVariable.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Reuses contextual-type computations and short-circuits const-type checks. |
Review effort: Balanced
Member
Author
|
TypeScript Bot (@typescript-bot) perf test this faster |
Contributor
Contributor
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This branch has not been deployed
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.
checkObjectLiteralMethodpreviously computed the contextual type twice when checkingisConstContext. Return the already-computed contextual type fromisConstContextExand add early-outs inisConstTypeVariable.