Skip to content

Commit

Permalink
Assume objects are always dirty.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Apr 17, 2016
1 parent 8cfb586 commit 6d24b87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
_propertySetter: function(property, value, effects, fromAbove,
origin, originalProperty) {
var old = this.__data__[property];
// NaN is always not equal to itself,
// if old and value are both NaN we treat them as equal
// x === x is 10x faster, and equivalent to !isNaN(x)
if (old !== value && (old === old || value === value)) {
if (this._isPropertyDirty(property, value, old) !== false) {
this.__data__[property] = value;
if (typeof value == 'object') {
this._clearPath(property);
Expand All @@ -64,6 +61,14 @@
return old;
},

_isPropertyDirty: function(property, value, old) {
// NaN is always not equal to itself,
// if old and value are both NaN we treat them as equal
// x === x is 10x faster, and equivalent to !isNaN(x)
return (old !== value && (old === old || value === value)) ||
typeof value == 'object';
},

// Called during _applyConfig (well-known downward data-flow hot path)
// in order to avoid firing notify events
// TODO(kschaaf): downward bindings (e.g. _applyEffectValue) should also
Expand Down
8 changes: 2 additions & 6 deletions src/standard/notify-path.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,11 @@
}
},

// Note: this implemetation only accepts key-based array paths
// Note: this implementation only accepts key-based array paths
_notifyPath: function(path, value, fromAbove, origin, originalProperty) {
// All path/value pairs are cached on `this.__data__`
var old = this.__data__[path];
// manual dirty checking for now...
// NaN is always not equal to itself,
// if old and value are both NaN we treat them as equal
// x === x is 10x faster, and equivalent to !isNaN(x)
if (old !== value && (old === old || value === value)) {
if (this._isPropertyDirty(path, value, old) !== false) {
this.__data__[path] = value;
if (typeof value == 'object') {
this._clearPath(path);
Expand Down

0 comments on commit 6d24b87

Please sign in to comment.