Skip to content

Commit

Permalink
Branch based on whether getters/setters are allowed when creating the…
Browse files Browse the repository at this point in the history
… prototype, rather than on each method call. Minor performance gain.

git-svn-id: https://svn.lojjic.net/zomby/trunk@825 8f8d9d7b-adf4-0310-9a85-ad1d9f542d00
  • Loading branch information
Jason Johnston committed Feb 8, 2009
1 parent ec2e609 commit 5c80857
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/main/javascript/zomby/model/ModelObject.js
Expand Up @@ -93,15 +93,23 @@ zomby.model.ModelObject = Base.extend(
return JSON.stringify(this);
},

getChanges : function() {
return useGettersAndSetters ? (this._changes || (this._changes = {})) : this;
},

resetChanges : function() {
if(useGettersAndSetters) {
this._changes = {};
}
}
getChanges : (function() { //branch up-front rather than on each call
return useGettersAndSetters ?
function() {
return (this._changes || (this._changes = {}));
} :
function() {
return this;
};
})(),

resetChanges : (function() { //branch up-front rather than on each call
return useGettersAndSetters ?
function() {
this._changes = {};
} :
function() {};
})()

},
/** @scope zomby.model.ModelObject */
Expand Down

0 comments on commit 5c80857

Please sign in to comment.