timers: avoid generating holey internal arrays

PR-URL: https://github.com/nodejs/node/pull/54771
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Gürgün Dayıoğlu 2024-09-10 14:48:04 +02:00 committed by GitHub
parent 741004a3b8
commit 26b03c1b79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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