visitNodesWithoutCopyingPositions always makes a new NodeArray#59137
Merged
DanielRosenwasser merged 2 commits intomicrosoft:mainfrom Jul 16, 2024
Merged
visitNodesWithoutCopyingPositions always makes a new NodeArray#59137DanielRosenwasser merged 2 commits intomicrosoft:mainfrom
visitNodesWithoutCopyingPositions always makes a new NodeArray#59137DanielRosenwasser merged 2 commits intomicrosoft:mainfrom
Conversation
Member
Author
|
@typescript-bot perf test this |
Collaborator
src/compiler/checker.ts
Outdated
| if (result.pos !== -1 || result.end !== -1) { | ||
| if (result === nodes) { | ||
| result = factory.createNodeArray(nodes, nodes.hasTrailingComma); | ||
| result = factory.createNodeArray([...nodes], nodes.hasTrailingComma); |
Member
There was a problem hiding this comment.
I believe slice() tends to be a little faster than spreading since engines have to do shenanigans to support non-array iterables.
Suggested change
| result = factory.createNodeArray([...nodes], nodes.hasTrailingComma); | |
| result = factory.createNodeArray(nodes.slice(), nodes.hasTrailingComma); |
Collaborator
|
@iisaduan Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Member
Author
|
@typescript-bot perf test this |
Collaborator
Collaborator
|
@iisaduan Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
andrewbranch
approved these changes
Jul 8, 2024
weswigham
approved these changes
Jul 8, 2024
Member
|
@typescript-bot cherry pick this to release-5.5 |
Member
|
@typescript-bot cherry-pick this to release-5.5 |
Collaborator
Collaborator
|
Hey, @DanielRosenwasser! I've created #59179 for you. |
DanielRosenwasser
pushed a commit
that referenced
this pull request
Jul 16, 2024
…e-5.5 (#59179) Co-authored-by: Isabel Duan <isabelduan@microsoft.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
fixes #59115
The original call assumed
createNodeArrayalways makes a newNodeArray, however, in some instances (when there are no changes to theNodeArray), the original array returns. Unpacking the array makes sure that a newNodeArrayis always created.(Side note: As a lot of nodeFactory functions make a distinction between when it is always new node vs it is possible to return the old one, ie
createTvsupdateT,createNodeArraydoesn't currently follow that convention. A bigger version of this PR would be to change the behavior ofcreateNodeArray(such as #59135, but it could/would have other side effects), or to make two___NodeArrayfunctions that makes this distinction)