Skip to content

Commit

Permalink
perf_hooks: remove unnecessary bind
Browse files Browse the repository at this point in the history
Pass through parameters using setImmediate rather
than using Function.prototype.bind to bind the
provided context.

PR-URL: #28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
apapirovski authored and MylesBorins committed Dec 17, 2019
1 parent 7a756cb commit 4e67d38
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/perf_hooks.js
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 4e67d38

Please sign in to comment.