Skip to content

Commit

Permalink
timers: avoid generating holey internal arrays
Browse files Browse the repository at this point in the history
PR-URL: #54771
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
gurgunday authored and aduh95 committed Sep 13, 2024
1 parent 375cbb5 commit 3d47872
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'use strict';

const {
ArrayPrototypePush,
MathTrunc,
ObjectDefineProperties,
ObjectDefineProperty,
Expand Down Expand Up @@ -154,7 +155,7 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
args = [arg1, arg2, arg3];
for (i = 5; i < arguments.length; i++) {
// Extend array dynamically, makes .apply run much faster in v6.0.0
args[i - 2] = arguments[i];
ArrayPrototypePush(args, arguments[i]);
}
break;
}
Expand Down Expand Up @@ -224,7 +225,7 @@ function setInterval(callback, repeat, arg1, arg2, arg3) {
args = [arg1, arg2, arg3];
for (i = 5; i < arguments.length; i++) {
// Extend array dynamically, makes .apply run much faster in v6.0.0
args[i - 2] = arguments[i];
ArrayPrototypePush(args, arguments[i]);
}
break;
}
Expand Down Expand Up @@ -296,7 +297,7 @@ function setImmediate(callback, arg1, arg2, arg3) {
args = [arg1, arg2, arg3];
for (i = 4; i < arguments.length; i++) {
// Extend array dynamically, makes .apply run much faster in v6.0.0
args[i - 1] = arguments[i];
ArrayPrototypePush(args, arguments[i]);
}
break;
}
Expand Down

0 comments on commit 3d47872

Please sign in to comment.