From aedb72e03b43ed863406cc34302edb5caa7e5150 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Tue, 4 Oct 2016 18:28:26 -0500 Subject: [PATCH] process: improve performance of nextTick MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Roman Reiss Reviewed-By: Ilkka Myller Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Johan Bergström Reviewed-By: Trevor Norris --- lib/internal/process/next_tick.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js index 529645aa8d65c4..f27ef622a96e6a 100644 --- a/lib/internal/process/next_tick.js +++ b/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]++; } }