mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
minor performance refactor
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user