From a4447461119d923925d9fec5f607e62dfa1ff35a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 17 Jun 2024 16:20:42 -0400 Subject: [PATCH] simplify --- .../svelte/src/internal/client/constants.js | 1 - .../svelte/src/internal/client/runtime.js | 23 ++++--------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/packages/svelte/src/internal/client/constants.js b/packages/svelte/src/internal/client/constants.js index 4fc214d469..3c4ff97e37 100644 --- a/packages/svelte/src/internal/client/constants.js +++ b/packages/svelte/src/internal/client/constants.js @@ -5,7 +5,6 @@ export const BLOCK_EFFECT = 1 << 4; export const BRANCH_EFFECT = 1 << 5; export const ROOT_EFFECT = 1 << 6; export const UNOWNED = 1 << 7; -export const DISCONNECTED = 1 << 8; export const CLEAN = 1 << 9; export const DIRTY = 1 << 10; export const MAYBE_DIRTY = 1 << 11; diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index ca6e1d32ff..1f87d9cb76 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -28,7 +28,6 @@ import { BLOCK_EFFECT, ROOT_EFFECT, LEGACY_DERIVED_PROP, - DISCONNECTED, STATE_FROZEN_SYMBOL, INSPECT_EFFECT } from './constants.js'; @@ -157,14 +156,11 @@ export function is_runes() { */ export function check_dirtiness(reaction) { var flags = reaction.f; - var is_dirty = (flags & DIRTY) !== 0; - if (is_dirty) { - return true; - } + var is_dirty = (flags & DIRTY) !== 0; + if (is_dirty) return true; - var is_unowned = (flags & UNOWNED) !== 0; - var is_disconnected = (flags & DISCONNECTED) !== 0; + var is_derived = (flags & DERIVED) !== 0; if ((flags & MAYBE_DIRTY) !== 0) { var dependencies = reaction.deps; @@ -179,7 +175,7 @@ export function check_dirtiness(reaction) { update_derived(/** @type {import('#client').Derived} **/ (dependency), true); } - if (is_unowned || is_disconnected) { + if (is_derived) { // TODO why is this happening here rather than in `update_derived`? if (!dependency.reactions?.includes(reaction)) { (dependency.reactions ??= []).push(reaction); @@ -196,13 +192,9 @@ export function check_dirtiness(reaction) { } // Unowned signals are always maybe dirty, as we instead check their dependency versions. - if (!is_unowned) { + if ((flags & UNOWNED) === 0) { set_signal_status(reaction, CLEAN); } - - if (is_disconnected) { - reaction.f ^= DISCONNECTED; - } } return is_dirty; @@ -384,11 +376,6 @@ function remove_reaction(signal, dependency) { // allowing it to either reconnect in the future, or be GC'd by the VM. if (reactions_length === 0 && (dependency.f & DERIVED) !== 0) { set_signal_status(dependency, MAYBE_DIRTY); - // If we are working with a derived that is owned by an effect, then mark it as being - // disconnected. - if ((dependency.f & (UNOWNED | DISCONNECTED)) === 0) { - dependency.f ^= DISCONNECTED; - } remove_reactions(/** @type {import('#client').Derived} **/ (dependency), 0); } }