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 committed Jan 29, 2018
1 parent 5c8ce90 commit eb34278
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 @@ -218,11 +218,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 @@ -291,7 +291,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 eb34278

Please sign in to comment.