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 <[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]>
  • 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
Original file line number Diff line number Diff line change
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.