Skip to content

Commit

Permalink
only check deepEqual when not new
Browse files Browse the repository at this point in the history
all updates on new docs will be marked modified anyway

pref improvement
  • Loading branch information
aheckmann committed Aug 31, 2011
1 parent f1ecc0a commit 49a1919
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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++) {
Expand Down

0 comments on commit 49a1919

Please sign in to comment.