imrove $orderBy performance

This commit is contained in:
Misko Hevery 2010-05-30 20:21:40 -07:00
parent 2e33e89a77
commit 81dac70e72
2 changed files with 9 additions and 8 deletions

View file

@ -244,18 +244,17 @@ function copy(source, destination){
while(destination.length) {
destination.pop();
}
for ( var i = 0; i < source.length; i++) {
destination.push(copy(source[i]));
}
} else {
foreach(destination, function(value, key){
delete destination[key];
});
for ( var key in source) {
destination[key] = copy(source[key]);
}
}
foreach(source, function(value, key){
destination[key] = value ?
( isArray(value) ?
copy(value, []) :
(isObject(value) ? copy(value, {}) : value)) :
value;
});
return destination;
}
}

View file

@ -190,7 +190,9 @@ var angularArray = {
}
return 0;
};
return copy(array).sort(reverse(comparator, descend));
var arrayCopy = [];
for ( var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); }
return arrayCopy.sort(reverse(comparator, descend));
},
'orderByToggle':function(predicate, attribute) {
var STRIP = /^([+|-])?(.*)/;