From eaea7a14d8a29c06142dd8045d54dcd6b61bd3dd Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Fri, 9 Dec 2016 15:37:32 -0500 Subject: [PATCH] timers: cleanup extraneous property on Immediates This was originally changed in 6f75b6672ca08c2bc3bf5fe14abb1a9648601e2 but it appears unnecessary and benhcmark results show little difference without the extra property. Refs: https://github.com/nodejs/node/pull/6436 --- lib/timers.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/timers.js b/lib/timers.js index 0444b3de1cc64e..ce27be69450249 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -727,8 +727,6 @@ function processImmediate() { if (domain) domain.enter(); - immediate._callback = immediate._onImmediate; - // Save next in case `clearImmediate(immediate)` is called from callback var next = immediate._idleNext; @@ -764,8 +762,8 @@ function tryOnImmediate(immediate, oldTail) { runCallback(immediate); threw = false; } finally { - // clearImmediate checks _callback === null for kDestroy hooks. - immediate._callback = null; + // clearImmediate checks _onImmediate === null for kDestroy hooks. + immediate._onImmediate = null; if (!threw) emitAfter(immediate[async_id_symbol]); if (async_hook_fields[kDestroy] > 0 && !immediate._destroyed) { @@ -794,21 +792,21 @@ function tryOnImmediate(immediate, oldTail) { function runCallback(timer) { const argv = timer._argv; const argc = argv ? argv.length : 0; - if (typeof timer._callback !== 'function') - return promiseResolve(timer._callback, argv[0]); + if (typeof timer._onImmediate !== 'function') + return promiseResolve(timer._onImmediate, argv[0]); switch (argc) { // fast-path callbacks with 0-3 arguments case 0: - return timer._callback(); + return timer._onImmediate(); case 1: - return timer._callback(argv[0]); + return timer._onImmediate(argv[0]); case 2: - return timer._callback(argv[0], argv[1]); + return timer._onImmediate(argv[0], argv[1]); case 3: - return timer._callback(argv[0], argv[1], argv[2]); + return timer._onImmediate(argv[0], argv[1], argv[2]); // more than 3 arguments run slower with .apply default: - return Function.prototype.apply.call(timer._callback, timer, argv); + return Function.prototype.apply.call(timer._onImmediate, timer, argv); } } @@ -818,7 +816,7 @@ function Immediate() { // so have caller annotate the object (node v6.0.0, v8 5.0.71.35) this._idleNext = null; this._idlePrev = null; - this._callback = null; + this._onImmediate = null; this._argv = null; this._onImmediate = null; this._destroyed = false; @@ -869,7 +867,6 @@ exports.setImmediate = setImmediate; function createImmediate(args, callback) { // declaring it `const immediate` causes v6.0.0 to deoptimize this function var immediate = new Immediate(); - immediate._callback = callback; immediate._argv = args; immediate._onImmediate = callback; @@ -888,7 +885,7 @@ exports.clearImmediate = function(immediate) { if (!immediate) return; if (async_hook_fields[kDestroy] > 0 && - immediate._callback !== null && + immediate._onImmediate !== null && !immediate._destroyed) { emitDestroy(immediate[async_id_symbol]); immediate._destroyed = true;