Skip to content

Commit 96e53c6

Browse files
committed
fix: declare onCurrentListenersMutation on prototype
1 parent d8b83e4 commit 96e53c6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/core/data/dom-events/dom-event.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,19 @@ export class DOMEvent implements Event {
257257

258258
// Creating this upon class construction as an arrow function rather than as
259259
// an inline function bound afresh on each usage saves about 210 nanoseconds
260-
// per run of handleEvent().
261-
private onCurrentListenersMutation = () => {
260+
// per run of dispatchTo().
261+
//
262+
// Creating it on the prototype and calling with the context instead saves a
263+
// further 125 nanoseconds per run of dispatchTo().
264+
//
265+
// Creating it on the prototype and binding the context instead saves a
266+
// further 30 nanoseconds per run of dispatchTo().
267+
private onCurrentListenersMutation() {
262268
// Cloning the array via spread syntax is up to 180 nanoseconds
263269
// faster per run than using Array.prototype.slice().
264270
this.listenersLazyCopy = [...this.listenersLive];
265271
this.listenersLive.onMutation = null;
266-
};
272+
}
267273

268274
/**
269275
* Dispatches a synthetic event event to target and returns true if either

0 commit comments

Comments
 (0)