From 699dc6e4f7bb9c47d19a5d7200d57bd06b6c8c09 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Mon, 16 Dec 2024 20:05:08 +0000 Subject: [PATCH] fix: improve unowned derived performance (#14724) * fix: improve unowned derived performance * fix: improve unowned derived performance * changeset --- .changeset/many-worms-attend.md | 5 +++++ packages/svelte/src/internal/client/runtime.js | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/many-worms-attend.md diff --git a/.changeset/many-worms-attend.md b/.changeset/many-worms-attend.md new file mode 100644 index 000000000000..0da3699967f6 --- /dev/null +++ b/.changeset/many-worms-attend.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve unowned derived performance diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index ff8eaa8ef9bc..27e174d3aa73 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -230,8 +230,9 @@ export function check_dirtiness(reaction) { } } - // Unowned signals should never be marked as clean. - if (!is_unowned) { + // Unowned signals should never be marked as clean unless they + // are used within an active_effect without skip_reaction + if (!is_unowned || (active_effect !== null && !skip_reaction)) { set_signal_status(reaction, CLEAN); } }