@@ -16,7 +16,6 @@ export interface Link {
16
16
// Reused to link the previous stack in propagate
17
17
prevSub : Link | undefined ;
18
18
nextSub : Link | undefined ;
19
- // Reused to link the notify effect in queuedEffects
20
19
nextDep : Link | undefined ;
21
20
}
22
21
@@ -60,8 +59,7 @@ export function createReactiveSystem({
60
59
*/
61
60
notifyEffect ( effect : Subscriber ) : boolean ;
62
61
} ) {
63
- let queuedEffects : Subscriber | undefined ;
64
- let queuedEffectsTail : Subscriber | undefined ;
62
+ const queuedEffects : Subscriber [ ] = [ ] ;
65
63
66
64
return {
67
65
/**
@@ -146,22 +144,12 @@ export function createReactiveSystem({
146
144
continue ;
147
145
}
148
146
if ( subFlags & SubscriberFlags . Effect ) {
149
- if ( queuedEffectsTail !== undefined ) {
150
- queuedEffectsTail . depsTail ! . nextDep = sub . deps ;
151
- } else {
152
- queuedEffects = sub ;
153
- }
154
- queuedEffectsTail = sub ;
147
+ queuedEffects . push ( sub ) ;
155
148
}
156
149
} else if ( ! ( subFlags & ( SubscriberFlags . Tracking | targetFlag ) ) ) {
157
150
sub . flags = subFlags | targetFlag | SubscriberFlags . Notified ;
158
151
if ( ( subFlags & ( SubscriberFlags . Effect | SubscriberFlags . Notified ) ) === SubscriberFlags . Effect ) {
159
- if ( queuedEffectsTail !== undefined ) {
160
- queuedEffectsTail . depsTail ! . nextDep = sub . deps ;
161
- } else {
162
- queuedEffects = sub ;
163
- }
164
- queuedEffectsTail = sub ;
152
+ queuedEffects . push ( sub ) ;
165
153
}
166
154
} else if (
167
155
! ( subFlags & targetFlag )
@@ -313,17 +301,8 @@ export function createReactiveSystem({
313
301
* notifications may be triggered until fully handled.
314
302
*/
315
303
processEffectNotifications ( ) : void {
316
- while ( queuedEffects !== undefined ) {
317
- const effect = queuedEffects ;
318
- const depsTail = effect . depsTail ! ;
319
- const queuedNext = depsTail . nextDep ;
320
- if ( queuedNext !== undefined ) {
321
- depsTail . nextDep = undefined ;
322
- queuedEffects = queuedNext . sub ;
323
- } else {
324
- queuedEffects = undefined ;
325
- queuedEffectsTail = undefined ;
326
- }
304
+ while ( queuedEffects . length ) {
305
+ const effect = queuedEffects . shift ( ) ! ;
327
306
if ( ! notifyEffect ( effect ) ) {
328
307
effect . flags &= ~ SubscriberFlags . Notified ;
329
308
}
@@ -474,12 +453,7 @@ export function createReactiveSystem({
474
453
if ( ( subFlags & ( SubscriberFlags . PendingComputed | SubscriberFlags . Dirty ) ) === SubscriberFlags . PendingComputed ) {
475
454
sub . flags = subFlags | SubscriberFlags . Dirty | SubscriberFlags . Notified ;
476
455
if ( ( subFlags & ( SubscriberFlags . Effect | SubscriberFlags . Notified ) ) === SubscriberFlags . Effect ) {
477
- if ( queuedEffectsTail !== undefined ) {
478
- queuedEffectsTail . depsTail ! . nextDep = sub . deps ;
479
- } else {
480
- queuedEffects = sub ;
481
- }
482
- queuedEffectsTail = sub ;
456
+ queuedEffects . push ( sub ) ;
483
457
}
484
458
}
485
459
link = link . nextSub ! ;
0 commit comments