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 <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Weijia Wang <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • 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.