-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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: use new Empty() instead of Object.create(null) for performance #12172
base: main
Are you sure you want to change the base?
Conversation
❌ Deploy Preview for vue-sfc-playground failed.
|
0c87656
to
19480ca
Compare
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/shared
@vue/server-renderer
vue
@vue/compat
commit: |
It would be best to provide a benchmark to demonstrate that there is indeed a performance improvement. If the performance improvement is significant, then this PR is worthwhile. |
benchmark: jsbenchmark |
19480ca
to
92a4185
Compare
I'm getting similiar results to @Smrtnyk 's one on Edge 129/Chrome 129, but on Firefox both approaches give similar performance |
|
@Smrtnyk I can replicate your results in Chrome as well. I believe it's because the difference in V8 versions (Edge has V8 12.9.17.8 and Chrome V8 12.9.202.27) In either case, I also agree with Edison that this might be premature optimization, because this could easily change in a new JS engine version, I opened a similar issue at sindresorhus/eslint-plugin-unicorn#2455 and to some degree I agree with sindresorhus. Either way, I think it's a good refactor to move the creation logic into shared and import from there. |
Optimization: Use new Empty() instead of Object.create(null) for performance
v8 has a better optimization for initializing functions compared to Object