minor performance refactor

This commit is contained in:
KungD
2012-09-12 06:09:48 +02:00
parent a8388e2757
commit 43491f6f28

View File

@@ -741,9 +741,8 @@
options || (options = {});
if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
if (typeof this.comparator === "string"){
var compstr = this.comparator;
var compstr = this.comparator, attrName = compstr.replace(/^\+|\-/,"");
this.comparator = function(o1,o2){
var attrName = compstr.replace(/^\+|\-/,"");
return (o2.get(attrName) > o1.get(attrName) ? -1 : 1)*(compstr[0] === "-" ? -1 : 1);
}
}