events: optimize arrayClone by copying forward
Optimize arrayClone by copying forward. It's slightly faster (and more readable) to copy array elements in forward direction. This way it also avoids the ToBoolean and the postfix count operation. PR-URL: https://github.com/nodejs/node/pull/10571 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
parent
4198253a18
commit
f2f997ad1e
@ -477,9 +477,9 @@ function spliceOne(list, index) {
|
||||
list.pop();
|
||||
}
|
||||
|
||||
function arrayClone(arr, i) {
|
||||
var copy = new Array(i);
|
||||
while (i--)
|
||||
function arrayClone(arr, n) {
|
||||
var copy = new Array(n);
|
||||
for (var i = 0; i < n; ++i)
|
||||
copy[i] = arr[i];
|
||||
return copy;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user