Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6cb8a83

Browse filesBrowse files
committed
fix: don't share eventPath
1 parent 23961af commit 6cb8a83
Copy full SHA for 6cb8a83

File tree

1 file changed

+11
-11
lines changed
Filter options

1 file changed

+11
-11
lines changed

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

Copy file name to clipboardExpand all lines: packages/core/data/dom-events/dom-event.ts
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ const timeOrigin = Date.now();
1414
*/
1515
const emptyArray: ListenerEntry[] = [];
1616

17-
/**
18-
* Recycling the event path array rather than allocating a new one each time
19-
* saves about 210 nanoseconds per dispatchTo() call (and avoids memory pressure
20-
* and GC).
21-
*/
22-
const recycledEventPath: Observable[] = [];
23-
2417
enum EventPropagationState {
2518
resume,
2619
stop,
@@ -153,6 +146,13 @@ export class DOMEvent implements Event {
153146
// an event listener callback will end up modifying the listeners array.
154147
private declare listeners: ListenerEntry[];
155148

149+
/**
150+
* Recycling the event path array rather than allocating a new one each time
151+
* saves about 210 nanoseconds per dispatchTo() call (and avoids memory pressure
152+
* and GC).
153+
*/
154+
private readonly recycledEventPath: Observable[] = [];
155+
156156
/**
157157
* Returns the event's timestamp as the number of milliseconds measured
158158
* relative to the time origin.
@@ -200,15 +200,15 @@ export class DOMEvent implements Event {
200200
* [Button, StackLayout, Page] // 'bubble'
201201
*/
202202
private getEventPath(responder: Observable, path: 'capture' | 'bubble'): Observable[] {
203-
recycledEventPath.splice(0, recycledEventPath.length, responder);
203+
this.recycledEventPath.splice(0, this.recycledEventPath.length, responder);
204204

205205
if (!responder.isViewBase()) {
206-
return recycledEventPath;
206+
return this.recycledEventPath;
207207
}
208208

209209
// Determining the function up-front (rather than inside the loop) saves
210210
// 50 nanoseconds per dispatchTo() call.
211-
const insert = path === 'capture' ? recycledEventPath.unshift.bind(recycledEventPath) : recycledEventPath.push.bind(recycledEventPath);
211+
const insert = path === 'capture' ? this.recycledEventPath.unshift.bind(this.recycledEventPath) : this.recycledEventPath.push.bind(this.recycledEventPath);
212212

213213
let nextResponder = responder.parent;
214214
while (nextResponder) {
@@ -218,7 +218,7 @@ export class DOMEvent implements Event {
218218
// to then walk from Frame to Application or something.
219219
nextResponder = nextResponder?.parent;
220220
}
221-
return recycledEventPath;
221+
return this.recycledEventPath;
222222
}
223223

224224
/** @deprecated */

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.