documentcloud/backbone — pull request #1855 by caseywebdev (2012-11-30 23:43:48+00:00)
Title: Only sort on `add` when it make sense

Sorting on `add(models)` when `models` is empty is extremely wasteful. The same is true when adding models that already exist. It would also be wasteful to check these outside of the framework as `add` already iterates through all of the new models. This simple implementation can save a bunch of wasted computing for free.