Skip to content
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

lib: use <array>.push and <array>.unshift instead of <array>.concat #37239

Merged
merged 1 commit into from
Feb 26, 2021

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Feb 5, 2021

Using push and unshift methods is more performant than reassigning a
new array created with concat.

Benchmark for unshift: https://jsben.ch/KeLG4
Benchmark for push: https://jsben.ch/QtIzg

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Feb 5, 2021
@devsnek devsnek added the benchmark Issues and PRs related to the benchmark subsystem. label Feb 5, 2021
@aduh95 aduh95 force-pushed the no-array-concat branch 2 times, most recently from a0c23f6 to a8cf47e Compare February 5, 2021 17:39
@Trott
Copy link
Member

Trott commented Feb 6, 2021

Non-blocking questions:

Is performance important for any of the code paths changed here? Are any of these hot paths?

If so, can we benchmark?

@jasnell
Copy link
Member

jasnell commented Feb 23, 2021

Needs a rebase.

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 24, 2021
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Using `push` and `unshift` methods is more performant than reassigning a
new array created with `concat`.

PR-URL: nodejs#37239
Reviewed-By: James M Snell <jasnell@gmail.com>
@aduh95
Copy link
Contributor Author

aduh95 commented Feb 26, 2021

Landed in 83cce87

@aduh95 aduh95 merged commit 83cce87 into nodejs:master Feb 26, 2021
@aduh95 aduh95 deleted the no-array-concat branch February 26, 2021 10:13
targos pushed a commit that referenced this pull request Feb 28, 2021
Using `push` and `unshift` methods is more performant than reassigning a
new array created with `concat`.

PR-URL: #37239
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. benchmark Issues and PRs related to the benchmark subsystem. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants