Permalink
Browse files

only check deepEqual when not new

all updates on new docs will be marked modified anyway

pref improvement
  • Loading branch information...
1 parent f1ecc0a commit 49a1919e44fc9a38d167eddb9868969ba3f2fca1 @aheckmann aheckmann committed Aug 31, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/document.js
View
@@ -200,7 +200,6 @@ Document.prototype.set = function (path, val, type) {
}
if ('string' !== typeof path) {
-
if (null === path || undefined === path)
return this.set(val, path);
@@ -268,17 +267,19 @@ Document.prototype.set = function (path, val, type) {
if (!pathToMark) pathToMark = path;
}
- var markedModified = this.isDirectModified(pathToMark);
if ((!schema || null === val || undefined === val) ||
this.try(function(){
val = schema.applySetters(schema.cast(val, self), self);
})) {
- var priorVal = this.get(path);
-
- if (!markedModified && !deepEqual(val, priorVal)) {
+ if (this.isNew) {
this._activePaths.modify(pathToMark);
+ } else {
+ var priorVal = this.get(path);
+ if (!this.isDirectModified(pathToMark) && !deepEqual(val, priorVal)) {
+ this._activePaths.modify(pathToMark);
+ }
}
for (var i = 0, l = parts.length; i < l; i++) {

0 comments on commit 49a1919

Please sign in to comment.