chore: keep main's code where the branch's change isn't needed

- record block effects as maybe-dirty during traversal
- drop the extra DIRTY guard in #process
- delete deriveds from batch_values in mark_reactions
- don't queue a microtask flush in Batch.ensure during flushSync
- BranchManager commit loop
- capture order in update_derived
async-another-try-pt-1-prune
Rich Harris 20 hours ago
parent 8a7499d3cc
commit 8ec850dd12
No known key found for this signature in database

@ -110,16 +110,14 @@ export class BranchManager {
}
}
this.#batches.delete(batch);
for (const [b, k] of this.#batches) {
if (b.id > batch.id) {
this.#batches.delete(b);
if (b === batch) {
// keep values for newer batches
continue;
break;
}
this.#batches.delete(b);
const offscreen = this.#offscreen.get(k);
if (offscreen) {

@ -429,10 +429,9 @@ export class Batch {
// an if block that contains the last blocking pending effect falsy,
// causing the block to no longer be deferred.
for (const [reaction, status] of this.#dirty_reactions) {
if ((reaction.f & DERIVED) !== 0) {
set_signal_status(reaction, status);
} else if (status === DIRTY || (reaction.f & DIRTY) === 0) {
set_signal_status(reaction, status);
set_signal_status(reaction, status);
if ((reaction.f & DERIVED) === 0) {
this.schedule(/** @type {Effect} */ (reaction));
}
}
@ -585,6 +584,7 @@ export class Batch {
} else if (async_mode_flag && (flags & (RENDER_EFFECT | MANAGED_EFFECT)) !== 0) {
render_effects.push(effect);
} else if (is_dirty(effect)) {
if ((flags & BLOCK_EFFECT) !== 0) this.add_dirty_reaction(effect, MAYBE_DIRTY);
update_effect(effect);
}
@ -959,7 +959,7 @@ export class Batch {
if (current_batch === null) {
const batch = (current_batch = new Batch());
if (!is_processing) {
if (!is_processing && !is_flushing_sync) {
queue_micro_task(() => {
if (!batch.started) {
batch.flush();

@ -421,8 +421,8 @@ export function update_derived(derived) {
// to the previous batch, not the new one (which can already exist if an earlier
// effect wrote to a source). Not adding it to either can cause bugs, so we add it to both.
// See https://github.com/sveltejs/svelte/pull/18117 for more details.
previous_batch?.capture(derived, value, true);
current_batch?.capture(derived, value, true);
previous_batch?.capture(derived, value, true);
} else {
derived.v = value;
derived.wv = increment_write_version();

@ -416,6 +416,7 @@ function mark_reactions(signal, status, updated_during_traversal) {
} else if ((flags & DERIVED) !== 0) {
var derived = /** @type {Derived} */ (reaction);
batch_values?.delete(derived);
mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
} else if (not_dirty) {
var effect = /** @type {Effect} */ (reaction);

Loading…
Cancel
Save