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

"move to top" behavior uses slice, should use splice #87

Open
aduth opened this issue Nov 8, 2017 · 1 comment
Open

"move to top" behavior uses slice, should use splice #87

aduth opened this issue Nov 8, 2017 · 1 comment

Comments

@aduth
Copy link

aduth commented Nov 8, 2017

At this line, I expect you are intending to use Array#splice, not Array#slice:

entries.slice(cacheIndex, 1)

Splice is mutative and as used would result in the item being removed at the given index. Slice is non-mutative and as used does nothing (aside from wasting cycles to create a copy of the array starting at index 1), therefore the cache entry will exist twice in the entries set (since it is not removed, then later prepended to the set).

@jimmytuc
Copy link

Related #88

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

No branches or pull requests

2 participants