From 4e67d38f42a2f691201825b747ad82b354083f16 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 3e86f10e222441..3fb06f4e93dfa1 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -463,11 +463,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 @@ -493,11 +496,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; }