Skip to content

In createNodeArray, create a fresh array (2) #28441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants