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] Use Set so lookup of _dataListeners can be O(1) #1175

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

exoego
Copy link
Collaborator

@exoego exoego commented Apr 9, 2021

Partially adresses #926

This PR changes the internal _dataListeners from Array to Set, so lookup can be O(1) instead of O(n)
Original idea is proposed by @emarbo in #926 (comment)

Theoretically Set requires more memory than simple Array, but I think it can be negligible: the number of elements may be from dozens to hundreds for most cases.
Sacrificing some memory is rational improving time of destroying.

IIUC, Set is in all browsers supported by Vue 2.x: https://caniuse.com/?search=javascript%20set

@pr-triage pr-triage bot added the PR: draft label Apr 9, 2021
@exoego exoego marked this pull request as ready for review April 9, 2021 11:58
Copy link
Owner

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!
Great Job! 👍

@bigbossx
Copy link

bigbossx commented Aug 15, 2022

@exoego nice pr!

@exoego @kazupon
But should we consider more compatibility about Set like vue do that. Or we should add some compatibility warnings in docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged Type: Bug Bug or Bug fixes Type: Performance Includes performance fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants