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 <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>
  • Loading branch information
evanlucas committed Oct 13, 2016
1 parent 4f62acd commit 804d57d
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 804d57d

Please sign in to comment.