Skip to content

refactor(compiler-dom): use faster sets in vOn #275

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 2 commits into from

Conversation

CyberAP
Copy link
Contributor

@CyberAP CyberAP commented Oct 14, 2019

No description provided.

@yyx990803
Copy link
Member

Turns out a benchmark shows that in check or plain object access is about 5x faster than using Sets, mostly because the objects are static so their property access is well-optimized by the engine. We probably want to refactor all existing usage of Set checks to just plain objects.

To save the redundant { key: true }, we probably need something like Vue 2's makeMap utility.

@yyx990803 yyx990803 closed this Oct 14, 2019
@CyberAP
Copy link
Contributor Author

CyberAP commented Oct 14, 2019

Turns out a benchmark shows that in check or plain object access is about 5x faster than using Sets, mostly because the objects are static so their property access is well-optimized by the engine. We probably want to refactor all existing usage of Set checks to just plain objects.

To save the redundant { key: true }, we probably need something like Vue 2's makeMap utility.

Got it. Would you mind sharing a benchmark? At least in Chrome I wan't able to confirm that (example test on jsperf).

@CyberAP
Copy link
Contributor Author

CyberAP commented Oct 14, 2019

Made the test comparing four methods for that check and yes, objects are faster.
https://jsperf.com/in-operator-vs-indexof-vs-set-has/1

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.

2 participants