this.#scheduled can never be filled at this point

entangle-batches-2
Simon Holthausen 2 months ago
parent 451679a412
commit 014be9cccd
No known key found for this signature in database

@ -907,15 +907,11 @@ export class Batch {
this.#commit_callbacks = null; this.#commit_callbacks = null;
} }
// while flushing effects, a solitary batch with no pending async work and // While flushing effects, a solitary batch with no pending async work
// nothing scheduled is guaranteed to unlink at the end of this function, // is guaranteed to unlink at the end of this function, before any
// before any other batch could observe its `previous` values — recording // other batch could observe its `previous` values — recording them
// them for derived updates would be pure overhead // for derived updates would be pure overhead.
this.skip_previous = this.skip_previous = this.#pending === 0 && first_batch === this && last_batch === this;
this.#pending === 0 &&
this.#scheduled.length === 0 &&
first_batch === this &&
last_batch === this;
previous_batch = this; previous_batch = this;
flush_queued_effects(render_effects); flush_queued_effects(render_effects);
@ -926,7 +922,7 @@ export class Batch {
var next_batch = /** @type {Batch | null} */ (/** @type {unknown} */ (current_batch)); var next_batch = /** @type {Batch | null} */ (/** @type {unknown} */ (current_batch));
if (this.#pending === 0 && (this.#scheduled.length === 0 || next_batch !== null)) { if (this.#pending === 0) {
this.#unlink(); this.#unlink();
this.#release_waiter(); this.#release_waiter();
@ -942,21 +938,6 @@ export class Batch {
} }
} }
// Edge case: During traversal new branches might create effects that run immediately and set state,
// causing an effect to be scheduled again. We need to traverse the current batch
// once more in that case - most of the time this will just clean up dirty branches.
if (this.#scheduled.length > 0) {
if (next_batch !== null) {
for (const e of this.#scheduled) {
next_batch.#scheduled.push(e);
}
this.#scheduled = [];
} else {
next_batch = this;
}
}
if (next_batch !== null) { if (next_batch !== null) {
next_batch.#process(); next_batch.#process();
} }

Loading…
Cancel
Save