Repository: sveltejs/svelte
File: packages/svelte/src/internal/client/reactivity/sources.js (JavaScript)

Code before:
			(current_effect.f & BRANCH_EFFECT) === 0
		) {
			if (new_deps !== null && new_deps.includes(source)) {
				set_signal_status(current_effect, DIRTY);
				schedule_effect(current_effect);
			} else {
				if (current_untracked_writes === null) {
					set_current_untracked_writes([source]);
				} else {
					current_untracked_writes.push(source);
				}
			}
		}

		if (DEV && inspect_effects.size > 0) {
			const inspects = Array.from(inspect_effects);
			if (current_effect === null) {
				// Triggering an effect sync can tear the signal graph, so to avoid this we need
				// to ensure the graph has been flushed before triggering any inspect effects.
				// Only needed when there's currently no effect, and flushing with one present
				// could have other unintended consequences, like effects running out of order.
				// This is expensive, but given this is a DEV mode only feature, it should be fine
				flush_sync();
			}
			for (const effect of inspects) {
				// If the inspect effect is clean, mark it maybe dirty so we can avoid overfiring.
				if ((effect.f & CLEAN) !== 0) {
					set_signal_status(effect, MAYBE_DIRTY);
				}
				if (check_dirtiness(effect)) {
					update_effect(effect);
				}
			}
			inspect_effects.clear();
		}
	}

	return value;
}

/**
 * @param {Value} signal
 * @param {number} status should be DIRTY or MAYBE_DIRTY
 * @returns {void}
 */
function mark_reactions(signal, status) {
	var reactions = signal.reactions;
	if (reactions === null) return;

	var runes = is_runes();
	var length = reactions.length;

Review comment (suggestion):
```suggestion
				// Mark clean inspect-effects as maybe dirty and then check their dirtiness
				// instead of just updating the effects - this way we avoid overfiring.
```

Code after:
			(current_effect.f & BRANCH_EFFECT) === 0
		) {
			if (new_deps !== null && new_deps.includes(source)) {
				set_signal_status(current_effect, DIRTY);
				schedule_effect(current_effect);
			} else {
				if (current_untracked_writes === null) {
					set_current_untracked_writes([source]);
				} else {
					current_untracked_writes.push(source);
				}
			}
		}

		if (DEV && inspect_effects.size > 0) {
			const inspects = Array.from(inspect_effects);
			if (current_effect === null) {
				// Triggering an effect sync can tear the signal graph, so to avoid this we need
				// to ensure the graph has been flushed before triggering any inspect effects.
				// Only needed when there's currently no effect, and flushing with one present
				// could have other unintended consequences, like effects running out of order.
				// This is expensive, but given this is a DEV mode only feature, it should be fine
				flush_sync();
			}
			for (const effect of inspects) {
				// Mark clean inspect-effects as maybe dirty and then check their dirtiness
				// instead of just updating the effects - this way we avoid overfiring.
				if ((effect.f & CLEAN) !== 0) {
					set_signal_status(effect, MAYBE_DIRTY);
				}
				if (check_dirtiness(effect)) {
					update_effect(effect);
				}
			}
			inspect_effects.clear();
		}
	}

	return value;
}

/**
 * @param {Value} signal
 * @param {number} status should be DIRTY or MAYBE_DIRTY
 * @returns {void}
 */
function mark_reactions(signal, status) {
	var reactions = signal.reactions;
	if (reactions === null) return;

	var runes = is_runes();