Skip to content

Commit 4e67d38

Browse files
apapirovskiMylesBorins
authored andcommitted
perf_hooks: remove unnecessary bind
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>
1 parent 7a756cb commit 4e67d38

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/perf_hooks.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,14 @@ function getObserversList(type) {
463463
return list;
464464
}
465465

466-
function doNotify() {
467-
this[kQueued] = false;
468-
this.runInAsyncScope(this[kCallback], this, this[kBuffer], this);
469-
this[kBuffer][kEntries] = [];
470-
L.init(this[kBuffer][kEntries]);
466+
function doNotify(observer) {
467+
observer[kQueued] = false;
468+
observer.runInAsyncScope(observer[kCallback],
469+
observer,
470+
observer[kBuffer],
471+
observer);
472+
observer[kBuffer][kEntries] = [];
473+
L.init(observer[kBuffer][kEntries]);
471474
}
472475

473476
// Set up the callback used to receive PerformanceObserver notifications
@@ -493,11 +496,11 @@ function observersCallback(entry) {
493496
observer[kQueued] = true;
494497
// Use setImmediate instead of nextTick to give more time
495498
// for multiple entries to collect.
496-
setImmediate(doNotify.bind(observer));
499+
setImmediate(doNotify, observer);
497500
}
498501
} else {
499502
// If not buffering, notify immediately
500-
doNotify.call(observer);
503+
doNotify(observer);
501504
}
502505
current = current._idlePrev;
503506
}

0 commit comments

Comments
 (0)