Skip to content

Commit 0ef14b5

Browse files
authored
chore: more process_effect tweaks (#13315)
* consolidate more stuff * simpler * simplify * comment is unnecessary, this is the first time we read current_effect.first
1 parent 5d56c59 commit 0ef14b5

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export const EFFECT_TRANSPARENT = 1 << 15;
1818
export const LEGACY_DERIVED_PROP = 1 << 16;
1919
export const INSPECT_EFFECT = 1 << 17;
2020
export const HEAD_EFFECT = 1 << 18;
21-
export const EFFECT_QUEUED = 1 << 19;
22-
export const EFFECT_HAS_DERIVED = 1 << 20;
21+
export const EFFECT_HAS_DERIVED = 1 << 19;
2322

2423
export const STATE_SYMBOL = Symbol('$state');
2524
export const STATE_SYMBOL_METADATA = Symbol('$state metadata');

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

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import {
2222
BLOCK_EFFECT,
2323
ROOT_EFFECT,
2424
LEGACY_DERIVED_PROP,
25-
DISCONNECTED,
26-
EFFECT_QUEUED
25+
DISCONNECTED
2726
} from './constants.js';
2827
import { flush_tasks } from './dom/task.js';
2928
import { add_owner } from './dev/ownership.js';
@@ -512,8 +511,8 @@ function flush_queued_root_effects(root_effects) {
512511
for (var i = 0; i < length; i++) {
513512
var effect = root_effects[i];
514513

515-
if ((effect.f & EFFECT_QUEUED) !== 0) {
516-
effect.f ^= EFFECT_QUEUED;
514+
if ((effect.f & CLEAN) === 0) {
515+
effect.f ^= CLEAN;
517516
}
518517

519518
/** @type {Effect[]} */
@@ -593,15 +592,10 @@ export function schedule_effect(signal) {
593592
effect = effect.parent;
594593
var flags = effect.f;
595594

596-
if ((flags & BRANCH_EFFECT) !== 0) {
595+
if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
597596
if ((flags & CLEAN) === 0) return;
598597
effect.f ^= CLEAN;
599598
}
600-
601-
if ((flags & ROOT_EFFECT) !== 0) {
602-
if ((flags & EFFECT_QUEUED) !== 0) return;
603-
effect.f ^= EFFECT_QUEUED;
604-
}
605599
}
606600

607601
queued_root_effects.push(effect);
@@ -624,23 +618,18 @@ function process_effects(effect, collected_effects) {
624618

625619
main_loop: while (current_effect !== null) {
626620
var flags = current_effect.f;
627-
var is_active = (flags & INERT) === 0;
628621
var is_branch = (flags & BRANCH_EFFECT) !== 0;
629-
var is_clean = (flags & CLEAN) !== 0;
630-
var child = current_effect.first;
631-
632-
// Skip this branch if it's clean
633-
if (is_active && (!is_branch || !is_clean)) {
634-
if (is_branch) {
635-
set_signal_status(current_effect, CLEAN);
636-
}
622+
var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
637623

624+
if (!is_skippable_branch && (flags & INERT) === 0) {
638625
if ((flags & RENDER_EFFECT) !== 0) {
639-
if (!is_branch && check_dirtiness(current_effect)) {
626+
if (is_branch) {
627+
current_effect.f ^= CLEAN;
628+
} else if (check_dirtiness(current_effect)) {
640629
update_effect(current_effect);
641630
}
642-
// Child might have been mutated since running the effect or checking dirtiness
643-
child = current_effect.first;
631+
632+
var child = current_effect.first;
644633

645634
if (child !== null) {
646635
current_effect = child;

0 commit comments

Comments
 (0)