Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8eabc54

Browse files
kwypchlocaitp
authored andcommitted
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
1 parent 14ff529 commit 8eabc54

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/ng/filter/orderBy.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ function orderByFilter($parse) {
146146
return compare(get(a),get(b));
147147
}, descending);
148148
});
149-
var arrayCopy = [];
150-
for (var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); }
151-
return arrayCopy.sort(reverseComparator(comparator, reverseOrder));
149+
return slice.call(array).sort(reverseComparator(comparator, reverseOrder));
152150

153151
function comparator(o1, o2) {
154152
for (var i = 0; i < sortPredicate.length; i++) {

0 commit comments

Comments
 (0)