Skip to content
Permalink
Browse files

perf(limitTo): replace for loop with slice

  • Loading branch information
kwypchlo authored and lgalfaso committed Dec 15, 2014
1 parent 83f88c1 commit cd77c089ba2f4b94ccc74f32f0ffa9fb70851c02
Showing with 5 additions and 7 deletions.
  1. +5 −7 src/ng/filter/limitTo.js
@@ -106,8 +106,7 @@ function limitToFilter() {
}
}

var out = [],
i, n;
var i, n;

// if abs(limit) exceeds maximum length, trim it
if (limit > input.length)
@@ -119,14 +118,13 @@ function limitToFilter() {
i = 0;
n = limit;
} else {
// zero and NaN check on limit - return empty array
if (!limit) return [];

i = input.length + limit;
n = input.length;
}

for (; i < n; i++) {
out.push(input[i]);
}

return out;
return input.slice(i, n);
};
}

0 comments on commit cd77c08

Please sign in to comment.
You can’t perform that action at this time.