Skip to content

Commit 01bb876

Browse files
apapirovskitargos
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent baece55 commit 01bb876

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
@@ -455,11 +455,14 @@ function getObserversList(type) {
455455
return list;
456456
}
457457

458-
function doNotify() {
459-
this[kQueued] = false;
460-
this.runInAsyncScope(this[kCallback], this, this[kBuffer], this);
461-
this[kBuffer][kEntries] = [];
462-
L.init(this[kBuffer][kEntries]);
458+
function doNotify(observer) {
459+
observer[kQueued] = false;
460+
observer.runInAsyncScope(observer[kCallback],
461+
observer,
462+
observer[kBuffer],
463+
observer);
464+
observer[kBuffer][kEntries] = [];
465+
L.init(observer[kBuffer][kEntries]);
463466
}
464467

465468
// Set up the callback used to receive PerformanceObserver notifications
@@ -485,11 +488,11 @@ function observersCallback(entry) {
485488
observer[kQueued] = true;
486489
// Use setImmediate instead of nextTick to give more time
487490
// for multiple entries to collect.
488-
setImmediate(doNotify.bind(observer));
491+
setImmediate(doNotify, observer);
489492
}
490493
} else {
491494
// If not buffering, notify immediately
492-
doNotify.call(observer);
495+
doNotify(observer);
493496
}
494497
current = current._idlePrev;
495498
}

0 commit comments

Comments
 (0)