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>
This commit is contained in:
Evan Lucas authored and Myles Borins committed 2016-12-21 13:13:21 -05:00
1 parent 9703bf14ef
commit db10e94083
1 file changed
+5 -7
+5 -7
View File
@@ -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]++;
}
}