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

Code before:
		if (
			is_runes() &&
			current_effect !== null &&
			(current_effect.f & CLEAN) !== 0 &&
			(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.
				// This is expensive, but given this is a DEV mode only feature, it should be fine
				flush_sync();
			}
			for (const effect of inspects) {
				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;

	for (var i = 0; i < length; i++) {
		var reaction = reactions[i];
		var flags = reaction.f;

Review comment (performance):
Would be good to explain the if condition, hope I got that right
```suggestion
				// 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
```

Code after:
		if (
			is_runes() &&
			current_effect !== null &&
			(current_effect.f & CLEAN) !== 0 &&
			(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) {
				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;

	for (var i = 0; i < length; i++) {