address feedback

schedule_effect_perf
Dominic Gannaway 2 months ago
parent f745b9c7e9
commit 9baaf65a43

@ -9,15 +9,16 @@ export const DISCONNECTED = 1 << 8;
export const CLEAN = 1 << 9;
export const DIRTY = 1 << 10;
export const MAYBE_DIRTY = 1 << 11;
export const INERT = 1 << 12;
export const DESTROYED = 1 << 13;
export const EFFECT_RAN = 1 << 14;
export const EFFECT_HAS_DIRTY_CHILDREN = 1 << 12;
export const INERT = 1 << 13;
export const DESTROYED = 1 << 14;
export const EFFECT_RAN = 1 << 15;
/** 'Transparent' effects do not create a transition boundary */
export const EFFECT_TRANSPARENT = 1 << 15;
export const EFFECT_TRANSPARENT = 1 << 16;
/** Svelte 4 legacy mode props need to be handled with deriveds and be recognized elsewhere, hence the dedicated flag */
export const LEGACY_DERIVED_PROP = 1 << 16;
export const INSPECT_EFFECT = 1 << 17;
export const HEAD_EFFECT = 1 << 18;
export const LEGACY_DERIVED_PROP = 1 << 17;
export const INSPECT_EFFECT = 1 << 18;
export const HEAD_EFFECT = 1 << 19;
export const STATE_SYMBOL = Symbol('$state');
export const STATE_SYMBOL_METADATA = Symbol('$state metadata');

@ -22,7 +22,8 @@ import {
BLOCK_EFFECT,
ROOT_EFFECT,
LEGACY_DERIVED_PROP,
DISCONNECTED
DISCONNECTED,
EFFECT_HAS_DIRTY_CHILDREN
} from './constants.js';
import { flush_tasks } from './dom/task.js';
import { add_owner } from './dev/ownership.js';
@ -586,15 +587,9 @@ export function schedule_effect(signal) {
effect = effect.parent;
var flags = effect.f;
// Branch effects are not part of the reactive signal graph as they can never have
// dependencies. As such, we can use effects can be CLEAN or MAYBE_DIRTY to signal
// that they contain an effect that is dirty and needs visiting in `process_effects`,
// and if not we can skip the branch entirely. This also doubles as being able to
// skip propagation up the graph in `schedule_effect` if we encounter a branch that
// is already MAYBE_DIRTY.
if ((flags & BRANCH_EFFECT) !== 0) {
if ((flags & CLEAN) === 0) return;
set_signal_status(effect, MAYBE_DIRTY);
set_signal_status(effect, EFFECT_HAS_DIRTY_CHILDREN);
}
}
@ -626,7 +621,7 @@ function process_effects(effect, collected_effects) {
// Skip this branch if it's clean
if (is_active && (!is_branch || !is_clean)) {
if (is_branch) {
if ((flags & EFFECT_HAS_DIRTY_CHILDREN) !== 0) {
set_signal_status(current_effect, CLEAN);
}

Loading…
Cancel
Save