Skip to content

Commit a8a5b70

Browse files
committed
replace unshift with iterating ordered_effects in reverse
1 parent 739b511 commit a8a5b70

File tree

1 file changed

+4
-5
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+4
-5
lines changed

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,19 +610,18 @@ function flush_queued_effects(effects) {
610610

611611
// Run effects in order from ancestor to descendant, else we could run into nullpointers
612612
/** @type {Effect[]} */
613-
const ordered_effects = [];
613+
const ordered_effects = [e];
614614
let ancestor = e.parent;
615615
while (ancestor !== null) {
616616
if (eager_block_effects.has(ancestor)) {
617617
eager_block_effects.delete(ancestor);
618-
ordered_effects.unshift(ancestor);
618+
ordered_effects.push(ancestor);
619619
}
620620
ancestor = ancestor.parent;
621621
}
622622

623-
ordered_effects.push(e);
624-
625-
for (const e of ordered_effects) {
623+
for (let j = ordered_effects.length - 1; j >= 0; j--) {
624+
const e = ordered_effects[j];
626625
// Skip eager effects that have already been unmounted
627626
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
628627
update_effect(e);

0 commit comments

Comments
 (0)