Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Nov 9, 2018

Refreshing #20518

@ghost ghost requested a review from rbuckton November 9, 2018 19:51
return elements;
}
// elements is a ReadonlyArray, so create a fresh array before adding properties.
elements = elements.slice();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a scenario that breaks because of this? I think from below code looks like the intention of the code is to make elements array into node array?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is generally the purpose of this function, yes. elements was not always a ReadonlyArray, but now that it is it makes sense to make a fresh copy. We should verify the performance/memory characteristics of this change, however.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, mutating the array this way does not actually change its "ReadonlyArray"-ness, just promotes it to a Node Array (which is also a ReadonlyArray).

@ghost ghost assigned rbuckton Nov 16, 2018
@RyanCavanaugh
Copy link
Member

Unclear what this fixes and has conflicts now

@RyanCavanaugh RyanCavanaugh deleted the slice_node_array branch October 25, 2022 20:18
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants