diff options
author | Matteo Collina <hello@matteocollina.com> | 2018-01-25 21:51:56 +0800 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-01-29 08:04:55 +0400 |
commit | eb34278dccc85a572b307253983721929b3fb1a8 (patch) | |
tree | 8691ce5be59618efbb40131038b77a1974d1577c /lib/timers.js | |
parent | 5c8ce90c2f47fc4fe699bbfb62f7004c4192d6e2 (diff) | |
download | android-node-v8-eb34278dccc85a572b307253983721929b3fb1a8.tar.gz android-node-v8-eb34278dccc85a572b307253983721929b3fb1a8.tar.bz2 android-node-v8-eb34278dccc85a572b307253983721929b3fb1a8.zip |
timers: attach listOnTimeout function to TimerWrap
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib/timers.js')
-rw-r--r-- | lib/timers.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/timers.js b/lib/timers.js index a38829d2f0..db43a7491d 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -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; @@ -291,7 +291,7 @@ function listOnTimeout() { return; this.close(); -} +}; // An optimization so that the try/finally only de-optimizes (since at least v8 |