GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — timers: remove dead code and simplify args check · nodejs/node@143dbb3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • internal
      • timers.js
    • timers.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/timers.js‎

Copy file name to clipboardExpand all lines: lib/internal/timers.js
+2-23Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,13 @@ Timeout.prototype.refresh = function() {
102102
return this;
103103
};
104104

105-
function setUnrefTimeout(callback, after, arg1, arg2, arg3) {
105+
function setUnrefTimeout(callback, after) {
106106
// Type checking identical to setTimeout()
107107
if (typeof callback !== 'function') {
108108
throw new ERR_INVALID_CALLBACK();
109109
}
110110

111-
let i, args;
112-
switch (arguments.length) {
113-
// fast cases
114-
case 1:
115-
case 2:
116-
break;
117-
case 3:
118-
args = [arg1];
119-
break;
120-
case 4:
121-
args = [arg1, arg2];
122-
break;
123-
default:
124-
args = [arg1, arg2, arg3];
125-
for (i = 5; i < arguments.length; i++) {
126-
// Extend array dynamically, makes .apply run much faster in v6.0.0
127-
args[i - 2] = arguments[i];
128-
}
129-
break;
130-
}
131-
132-
const timer = new Timeout(callback, after, args, false);
111+
const timer = new Timeout(callback, after, undefined, false);
133112
getTimers()._unrefActive(timer);
134113

135114
return timer;
Collapse file

‎lib/timers.js‎

Copy file name to clipboardExpand all lines: lib/timers.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function listOnTimeout(list, now) {
323323

324324
try {
325325
const args = timer._timerArgs;
326-
if (!args)
326+
if (args === undefined)
327327
timer._onTimeout();
328328
else
329329
Reflect.apply(timer._onTimeout, timer, args);
@@ -462,8 +462,9 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
462462
}
463463

464464
setTimeout[internalUtil.promisify.custom] = function(after, value) {
465+
const args = value !== undefined ? [value] : value;
465466
return new Promise((resolve) => {
466-
active(new Timeout(resolve, after, [value], false));
467+
active(new Timeout(resolve, after, args, false));
467468
});
468469
};
469470

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.