documentcloud/backbone — pull request #1667 by braddunbar (2012-09-22 13:22:37+00:00)
Title: Fix #1604 - Refactor add, remove index option.

* Avoid temporary constructs by splicing duplicates during traversal.
* Remove `index` option to prevent traversing the entire collection.
* Avoid creating empty options.

Since `add` sorts via Array#sort, there is no way to get the index of all added models without traversing the entire collection (the current behavior). I don't think this is a sensible default since it does not scale well to many adds or many models. It's quite easy to retrieve the index of a model if needed via `indexOf`.

Also, I moved to reverse iteration over the models to prevent fiddling with indices during traversal. This could potentially change behavior of merging if there are multiple duplicates in the arguments but I don't think this is common or has ever been guaranteed.