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

Unnecessary sorting on change between models with same comparators #33

Open
ambischof opened this issue Jul 15, 2016 · 0 comments
Open

Comments

@ambischof
Copy link

Lets say we have a collection sorted on attribute 'name', and there are 4 entries with the name "Bob", if we change some other attribute, say 'age' on the second "Bob", it will remove that one and insert it at the beginning or the end of the "Bob"s, depending on directionality.

Cause:
If we consider line https://github.com/jmorrell/backbone.obscura/blob/master/backbone.obscura.js#L641, the algorithm checks to see where it would be inserted, and if its current index is different from the new index. However this doesn't take into account whether the comparator of the model at the new index is different from the comparator of the model in question. If they are the same, they shouldn't be resorted.

This can cause very disruptive changes, especially when there's a small number of unique comparators compared to the size of the list.

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

1 participant