Skip to content

Commit

Permalink
timers: attach listOnTimeout function to TimerWrap
Browse files Browse the repository at this point in the history
Make the listOnTimeout function inline by attaching it to the TimeWrap
prototype.
It improves insertion and cancellation time of unpooled timers by 18%
and 28% respectively.

PR-URL: #18388
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
mcollina authored and evanlucas committed Jan 30, 2018
1 parent 03cb069 commit 7b73e70
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ function TimersList(msecs, unrefed) {
if (unrefed === true)
timer.unref();
timer.start(msecs);

timer[kOnTimeout] = listOnTimeout;
}

function listOnTimeout() {
// adds listOnTimeout to the C++ object prototype, as
// V8 would not inline it otherwise.
TimerWrap.prototype[kOnTimeout] = function listOnTimeout() {
var list = this._list;
var msecs = list.msecs;

Expand Down Expand Up @@ -280,7 +280,7 @@ function listOnTimeout() {
return;

this.close();
}
};


// An optimization so that the try/finally only de-optimizes (since at least v8
Expand Down

0 comments on commit 7b73e70

Please sign in to comment.