documentcloud/backbone — pull request #1688 by tgriesser (2012-09-30 22:55:15+00:00)
Title: Refactoring change & set, fixing #1478 and #1664

This pull request fixes the `silent:true` set bug of #1478 and #1664, combining the changes @braddunbar made on #1618 to simplify the `change` & `set` methods, the approach used in #1562 to store & check against the current state of the model when in a nested change block, and changes one of the current test cases, which @stegrams points out in #1675 is incorrect.

Running the speed tests shows an improvement - I ran them three times each for the current version and the fix, and here are the results:

**Current:**

Model: set Math.random()
Model: set rand() with an event
Model: set rand() with an attribute observer

77490
53155
50531

74655
53432
50099

73460
52744
51549

**Fixed:**

Model: set Math.random()
Model: set rand() with an event
Model: set rand() with an attribute observer

95019
68272
59920

94799
69474
66217

95573
65897
60720

Showing an improvement in the patched version (thanks to @braddunbar's changes). Three additional tests are included for the cases where `A` -> `B (slient)` -> `A` change incorrectly triggers a change event.