Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove unnecessary bind #28131

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
perf_hooks: remove unnecessary bind
Pass through parameters using setImmediate rather
than using Function.prototype.bind to bind the
provided context.
  • Loading branch information
apapirovski committed Dec 13, 2019
commit 96067ca6f1c96a028968ec09eb99e01877e6c79f
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