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 targos committed Jan 14, 2020
1 parent baece55 commit 01bb876
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 01bb876

Please sign in to comment.