mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-13 08:59:54 +08:00
perf(orderBy): copy array with slice instead of for loop
Use array slice method to copy entire array instead of a for loop http://jsperf.com/new-array-vs-splice-vs-slice/54 Closes #9942
This commit is contained in:
committed by
Caitlin Potter
parent
e49a1433fd
commit
409bcb3810
@@ -146,9 +146,7 @@ function orderByFilter($parse){
|
||||
return compare(get(a),get(b));
|
||||
}, descending);
|
||||
});
|
||||
var arrayCopy = [];
|
||||
for ( var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); }
|
||||
return arrayCopy.sort(reverseComparator(comparator, reverseOrder));
|
||||
return slice.call(array).sort(reverseComparator(comparator, reverseOrder));
|
||||
|
||||
function comparator(o1, o2){
|
||||
for ( var i = 0; i < sortPredicate.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user