Skip to content

Commit

Permalink
process: improve performance of nextTick
Browse files Browse the repository at this point in the history
This replaces TickObject with an object literal. This offers
performance improvements of up to ~20%.

PR-URL: #8932
Reviewed-By: Claudio Rodriguez <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Ilkka Myller <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
  • Loading branch information
evanlucas authored and jasnell committed Oct 14, 2016
1 parent cde2ca9 commit aedb72e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/internal/process/next_tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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]++;
}
}

0 comments on commit aedb72e

Please sign in to comment.