@@ -142,7 +142,7 @@ export class Batch {
142142 }
143143
144144 for ( const root of root_effects ) {
145- process_effects ( this , root ) ;
145+ this . process_root ( root ) ;
146146 }
147147
148148 if ( this . async_effects . length === 0 && this . #pending === 0 ) {
@@ -234,6 +234,67 @@ export class Batch {
234234 this . boundary_async_effects = [ ] ;
235235 }
236236
237+ /**
238+ * @param {Effect } root
239+ */
240+ process_root ( root ) {
241+ root . f ^= CLEAN ;
242+
243+ var effect = root . first ;
244+
245+ while ( effect !== null ) {
246+ var flags = effect . f ;
247+ var is_branch = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) !== 0 ;
248+ var is_skippable_branch = is_branch && ( flags & CLEAN ) !== 0 ;
249+
250+ var skip = is_skippable_branch || ( flags & INERT ) !== 0 || this . skipped_effects . has ( effect ) ;
251+
252+ if ( ! skip && effect . fn !== null ) {
253+ if ( ( flags & EFFECT_ASYNC ) !== 0 ) {
254+ const boundary = effect . b ;
255+
256+ if ( check_dirtiness ( effect ) ) {
257+ var effects = boundary ?. pending ? this . boundary_async_effects : this . async_effects ;
258+ effects . push ( effect ) ;
259+ }
260+ } else if ( ( flags & BLOCK_EFFECT ) !== 0 ) {
261+ if ( check_dirtiness ( effect ) ) {
262+ update_effect ( effect ) ;
263+ }
264+ } else if ( is_branch ) {
265+ effect . f ^= CLEAN ;
266+ } else if ( ( flags & RENDER_EFFECT ) !== 0 ) {
267+ // we need to branch here because in legacy mode we run render effects
268+ // before running block effects
269+ if ( async_mode_flag ) {
270+ this . render_effects . push ( effect ) ;
271+ } else {
272+ if ( check_dirtiness ( effect ) ) {
273+ update_effect ( effect ) ;
274+ }
275+ }
276+ } else if ( ( flags & EFFECT ) !== 0 ) {
277+ this . effects . push ( effect ) ;
278+ }
279+
280+ var child = effect . first ;
281+
282+ if ( child !== null ) {
283+ effect = child ;
284+ continue ;
285+ }
286+ }
287+
288+ var parent = effect . parent ;
289+ effect = effect . next ;
290+
291+ while ( effect === null && parent !== null ) {
292+ effect = parent . next ;
293+ parent = parent . parent ;
294+ }
295+ }
296+ }
297+
237298 /**
238299 * @param {Source } source
239300 * @param {any } value
@@ -518,74 +579,6 @@ export function schedule_effect(signal) {
518579 queued_root_effects . push ( effect ) ;
519580}
520581
521- /**
522- *
523- * This function both runs render effects and collects user effects in topological order
524- * from the starting effect passed in. Effects will be collected when they match the filtered
525- * bitwise flag passed in only. The collected effects array will be populated with all the user
526- * effects to be flushed.
527- *
528- * @param {Batch } batch
529- * @param {Effect } root
530- */
531- export function process_effects ( batch , root ) {
532- root . f ^= CLEAN ;
533-
534- var effect = root . first ;
535-
536- while ( effect !== null ) {
537- var flags = effect . f ;
538- var is_branch = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) !== 0 ;
539- var is_skippable_branch = is_branch && ( flags & CLEAN ) !== 0 ;
540-
541- var skip = is_skippable_branch || ( flags & INERT ) !== 0 || batch . skipped_effects . has ( effect ) ;
542-
543- if ( ! skip && effect . fn !== null ) {
544- if ( ( flags & EFFECT_ASYNC ) !== 0 ) {
545- const boundary = effect . b ;
546-
547- if ( check_dirtiness ( effect ) ) {
548- var effects = boundary ?. pending ? batch . boundary_async_effects : batch . async_effects ;
549- effects . push ( effect ) ;
550- }
551- } else if ( ( flags & BLOCK_EFFECT ) !== 0 ) {
552- if ( check_dirtiness ( effect ) ) {
553- update_effect ( effect ) ;
554- }
555- } else if ( is_branch ) {
556- effect . f ^= CLEAN ;
557- } else if ( ( flags & RENDER_EFFECT ) !== 0 ) {
558- // we need to branch here because in legacy mode we run render effects
559- // before running block effects
560- if ( async_mode_flag ) {
561- batch . render_effects . push ( effect ) ;
562- } else {
563- if ( check_dirtiness ( effect ) ) {
564- update_effect ( effect ) ;
565- }
566- }
567- } else if ( ( flags & EFFECT ) !== 0 ) {
568- batch . effects . push ( effect ) ;
569- }
570-
571- var child = effect . first ;
572-
573- if ( child !== null ) {
574- effect = child ;
575- continue ;
576- }
577- }
578-
579- var parent = effect . parent ;
580- effect = effect . next ;
581-
582- while ( effect === null && parent !== null ) {
583- effect = parent . next ;
584- parent = parent . parent ;
585- }
586- }
587- }
588-
589582export function suspend ( ) {
590583 var boundary = get_pending_boundary ( ) ;
591584 var batch = /** @type {Batch } */ ( current_batch ) ;
0 commit comments