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

perf: match ownKeys perf to the one of objectSpread #10189



Copy link

@JLHwung JLHwung commented Jul 9, 2019

Q                       A
Fixed Issues? Fixes a performance regression introduced in #10171, Fixes #10192
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR addresses a performance regression introduced at #10171.

Object.keys returns a list of enumerable property names. Hence we filter enumerable only on the property symbols. Note that this approach is also practiced in helpers.objectSpread.

In practice the most frequent use cases of objectSpread is merging two plain objects, which means we can skip a sweep of already enumerable property names. I also drafted a jsPerf snippet on the performance difference. It is 10% faster on V8 75 when merging two object with 512 keys.

Copy link

@nicolo-ribaudo nicolo-ribaudo left a comment

Good catch!

Copy link

@babel-bot babel-bot commented Jul 9, 2019

Build successful! You can test your changes in the REPL here:

@JLHwung JLHwung force-pushed the JLHwung:object-spread2-performance-regression branch from d5f8af0 to 49f8d4c Jul 9, 2019
Copy link

@existentialism existentialism left a comment

👍 (especially the comment!)

Copy link

@nicolo-ribaudo nicolo-ribaudo commented Jul 9, 2019


(As a side note, I really like having more ✔️ than usual!)

EDIT: I was going to merge this PR, I'll wait for CI to finish.

Copy link
Contributor Author

@JLHwung JLHwung commented Jul 9, 2019

(especially the comment!)

The idea comes from discussion with @nicolo-ribaudo

@JLHwung JLHwung mentioned this pull request Jul 10, 2019
@existentialism existentialism merged commit 5d9a786 into babel:master Jul 11, 2019
4 checks passed
4 checks passed
babel/repl REPL preview is available
ci/circleci Your tests passed on CircleCI!
codecov/project 87.57% (target 80%)
continuous-integration/travis-ci/pr The Travis CI build passed
@JLHwung JLHwung deleted the JLHwung:object-spread2-performance-regression branch Jul 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants