@@ -14,13 +14,6 @@ const timeOrigin = Date.now();
14
14
*/
15
15
const emptyArray : ListenerEntry [ ] = [ ] ;
16
16
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
-
24
17
enum EventPropagationState {
25
18
resume ,
26
19
stop ,
@@ -153,6 +146,13 @@ export class DOMEvent implements Event {
153
146
// an event listener callback will end up modifying the listeners array.
154
147
private declare listeners : ListenerEntry [ ] ;
155
148
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
+
156
156
/**
157
157
* Returns the event's timestamp as the number of milliseconds measured
158
158
* relative to the time origin.
@@ -200,15 +200,15 @@ export class DOMEvent implements Event {
200
200
* [Button, StackLayout, Page] // 'bubble'
201
201
*/
202
202
private getEventPath ( responder : Observable , path : 'capture' | 'bubble' ) : Observable [ ] {
203
- recycledEventPath . splice ( 0 , recycledEventPath . length , responder ) ;
203
+ this . recycledEventPath . splice ( 0 , this . recycledEventPath . length , responder ) ;
204
204
205
205
if ( ! responder . isViewBase ( ) ) {
206
- return recycledEventPath ;
206
+ return this . recycledEventPath ;
207
207
}
208
208
209
209
// Determining the function up-front (rather than inside the loop) saves
210
210
// 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 ) ;
212
212
213
213
let nextResponder = responder . parent ;
214
214
while ( nextResponder ) {
@@ -218,7 +218,7 @@ export class DOMEvent implements Event {
218
218
// to then walk from Frame to Application or something.
219
219
nextResponder = nextResponder ?. parent ;
220
220
}
221
- return recycledEventPath ;
221
+ return this . recycledEventPath ;
222
222
}
223
223
224
224
/** @deprecated */
0 commit comments