Skip to content

Commit 3ee25bb

Browse files
committed
reinstate scheduling optimisation
1 parent 1f02fdf commit 3ee25bb

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { Boundary } from './dom/blocks/boundary.js';
5151
import * as w from './warnings.js';
5252
import { is_firefox } from './dom/operations.js';
5353
import { current_batch, Batch, remove_current_batch } from './reactivity/batch.js';
54+
import { log_effect_tree, root } from './dev/debug.js';
5455

5556
// Used for DEV time error handling
5657
/** @param {WeakSet<Error>} value */
@@ -813,20 +814,12 @@ export function schedule_effect(signal) {
813814
var flags = effect.f;
814815

815816
if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
816-
// TODO reinstate this
817-
// if ((flags & CLEAN) === 0) return;
818-
// effect.f ^= CLEAN;
819-
820-
if ((flags & CLEAN) !== 0) {
821-
effect.f ^= CLEAN;
822-
}
817+
if ((flags & CLEAN) === 0) return;
818+
effect.f ^= CLEAN;
823819
}
824820
}
825821

826-
// TODO reinstate early bail-out when traversing up the graph
827-
if (!queued_root_effects.includes(effect)) {
828-
queued_root_effects.push(effect);
829-
}
822+
queued_root_effects.push(effect);
830823
}
831824

832825
/**
@@ -847,7 +840,7 @@ function process_effects(root, async_effects, render_effects, effects) {
847840

848841
while (effect !== null) {
849842
var flags = effect.f;
850-
var is_branch = (flags & BRANCH_EFFECT) !== 0;
843+
var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
851844
var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
852845

853846
var skip = is_skippable_branch || (flags & INERT) !== 0 || batch.skipped_effects.has(effect);
@@ -865,13 +858,10 @@ function process_effects(root, async_effects, render_effects, effects) {
865858
} catch (error) {
866859
handle_error(error, effect, null, effect.ctx);
867860
}
861+
} else if (is_branch) {
862+
effect.f ^= CLEAN;
868863
} else if ((flags & RENDER_EFFECT) !== 0) {
869-
if (is_branch) {
870-
// TODO clean branch later, if batch is settled
871-
// current_effect.f ^= CLEAN;
872-
} else {
873-
render_effects.push(effect);
874-
}
864+
render_effects.push(effect);
875865
} else if ((flags & EFFECT) !== 0) {
876866
effects.push(effect);
877867
}

0 commit comments

Comments
 (0)