From ef9d40aa82d452459caab3d20ead4bc5967636c5 Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Mon, 30 Jan 2012 13:28:34 -0500 Subject: [PATCH] factor away else branch --- backbone.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/backbone.js b/backbone.js index b03b2c54..8ac51624 100644 --- a/backbone.js +++ b/backbone.js @@ -395,17 +395,16 @@ // You can also pass an attributes object to diff against the model, // determining if there *would be* a change. changedAttributes: function(diff) { - var changed = false, old = this._previousAttributes; if (diff) { + var val, changed = false, old = this._previousAttributes; for (var attr in diff) { - if (_.isEqual(old[attr], diff[attr])) continue; - (changed || (changed = {}))[attr] = diff[attr]; + if (_.isEqual(old[attr], (val = diff[attr]))) continue; + (changed || (changed = {}))[attr] = val; } return changed; - } else { - if (!this.hasChanged()) return false; - return _.clone(this._changed); } + if (!this.hasChanged()) return false; + return _.clone(this._changed); }, // Get the previous value of an attribute, recorded at the time the last