documentcloud/backbone — pull request #1905 by caseywebdev (2012-12-12 18:38:25+00:00)
Title: Simplify/robustify `update`

Some reasoning:

- `add`/`remove`/`reset` can all take non-array arguments (or even single model arguments) without breaking, so I think that's a fair assumption for `update`.
- proxy to `add` in the case mentioned saves a duplicate iteration of `models`.
- `modelsMap` only needs to be assigned values when `options.remove` is true.
- `modelsMap` only needs to store the `cid`, as we are guaranteed in the proceeding loop to have models with `cid`s
- Since we're already iterating `models`, we can intelligently only add models to the `add` array based on the options, saving loops in the `add` function.

The difference is SLOC is +2 (ignoring empty lines/comments), for what seems to me like some nice benefits. For your consideration...