Browse Source

process: improve performance of nextTick

This replaces TickObject with an object literal. This offers
performance improvements of up to ~20%.

PR-URL: https://github.com/nodejs/node/pull/8932
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v6.x
Evan Lucas 8 years ago
committed by Myles Borins
parent
commit
db10e94083
  1. 12
      lib/internal/process/next_tick.js

12
lib/internal/process/next_tick.js

@ -131,12 +131,6 @@ function setupNextTick() {
} while (tickInfo[kLength] !== 0);
}
function TickObject(c, args) {
this.callback = c;
this.domain = process.domain || null;
this.args = args;
}
function nextTick(callback) {
if (typeof callback !== 'function')
throw new TypeError('callback is not a function');
@ -151,7 +145,11 @@ function setupNextTick() {
args[i - 1] = arguments[i];
}
nextTickQueue.push(new TickObject(callback, args));
nextTickQueue.push({
callback,
domain: process.domain || null,
args
});
tickInfo[kLength]++;
}
}

Loading…
Cancel
Save