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: switch to object spread where possible #25104

Closed
wants to merge 1 commit into
base: master
from

Conversation

@BridgeAR
Copy link
Member

BridgeAR commented Dec 18, 2018

Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.

Benchmark with 11.4:

// node benchmark/es/spread-assign.js 
es/spread-assign.js n=1000000 count=5 method="spread": 36,495,416.66835458
es/spread-assign.js n=1000000 count=10 method="spread": 31,889,730.923060697
es/spread-assign.js n=1000000 count=20 method="spread": 151,930.52448171392
es/spread-assign.js n=1000000 count=5 method="assign": 9,476,496.804852217
es/spread-assign.js n=1000000 count=10 method="assign": 4,704,920.0252048215
es/spread-assign.js n=1000000 count=20 method="assign": 123,309.56193177585
es/spread-assign.js n=1000000 count=5 method="_extend": 5,076,862.324845331
es/spread-assign.js n=1000000 count=10 method="_extend": 2,359,288.3170930305
es/spread-assign.js n=1000000 count=20 method="_extend": 382,746.2281006062
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
lib: switch to object spread where possible
Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.
@BridgeAR

This comment has been minimized.

Copy link
Member

BridgeAR commented Dec 18, 2018

found a point we should address

@@ -136,7 +136,7 @@ function normalizeExecArgs(command, options, callback) {
}

// Make a shallow copy so we don't clobber the user's options object.
options = Object.assign({}, options);

This comment has been minimized.

@devsnek

devsnek Dec 18, 2018

Member

i realize this isn't directly related but it would be good to avoid assigning to the argument.

This comment has been minimized.

@BridgeAR

BridgeAR Dec 18, 2018

Member

We do that pretty often everywhere throughout the code?

This comment has been minimized.

@devsnek

devsnek Dec 18, 2018

Member

could be a separate pr i guess... i just figured as long as you're modifying a bunch of these you could change the argument name. non blocking.

@BridgeAR BridgeAR removed the author ready label Dec 18, 2018

@targos

targos approved these changes Dec 18, 2018

@lpinca

lpinca approved these changes Dec 18, 2018

BridgeAR added a commit to BridgeAR/node that referenced this pull request Dec 20, 2018

lib: switch to object spread where possible
Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.

PR-URL: nodejs#25104
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@BridgeAR

This comment has been minimized.

Copy link
Member

BridgeAR commented Dec 20, 2018

Landed in 4b7a530 🎉

@BridgeAR BridgeAR closed this Dec 20, 2018

tshemsedinov added a commit to metarhia/impress that referenced this pull request Dec 20, 2018

MylesBorins added a commit that referenced this pull request Dec 25, 2018

lib: switch to object spread where possible
Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.

PR-URL: #25104
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

@MylesBorins MylesBorins referenced this pull request Dec 25, 2018

Merged

v11.6.0 proposal #25175

MylesBorins added a commit that referenced this pull request Dec 26, 2018

lib: switch to object spread where possible
Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.

PR-URL: #25104
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

refack added a commit to refack/node that referenced this pull request Jan 14, 2019

lib: switch to object spread where possible
Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.

PR-URL: nodejs#25104
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment