From 25ba7f4d7cdc691d7b354875f2768f0f5f9579de Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Fri, 7 Jun 2019 22:42:32 +0200 Subject: [PATCH] perf_hooks: remove unnecessary bind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass through parameters using setImmediate rather than using Function.prototype.bind to bind the provided context. PR-URL: https://github.com/nodejs/node/pull/28131 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Tobias Nießen Reviewed-By: Ruben Bridgewater --- lib/perf_hooks.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 18b0332feaffaa..dbaf2a39fe6d19 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -455,11 +455,14 @@ function getObserversList(type) { return list; } -function doNotify() { - this[kQueued] = false; - this.runInAsyncScope(this[kCallback], this, this[kBuffer], this); - this[kBuffer][kEntries] = []; - L.init(this[kBuffer][kEntries]); +function doNotify(observer) { + observer[kQueued] = false; + observer.runInAsyncScope(observer[kCallback], + observer, + observer[kBuffer], + observer); + observer[kBuffer][kEntries] = []; + L.init(observer[kBuffer][kEntries]); } // Set up the callback used to receive PerformanceObserver notifications @@ -485,11 +488,11 @@ function observersCallback(entry) { observer[kQueued] = true; // Use setImmediate instead of nextTick to give more time // for multiple entries to collect. - setImmediate(doNotify.bind(observer)); + setImmediate(doNotify, observer); } } else { // If not buffering, notify immediately - doNotify.call(observer); + doNotify(observer); } current = current._idlePrev; }