chore: reduce indirection, simplify logic in batch.process(...) (#17521)

* chore: reduce indirection, simplify logic in batch.process(...)

* this is unnecessary, previous_batch is only read in specific effects that run later
pull/17501/head
Rich Harris 6 months ago committed by GitHub
parent 1ed458edc7
commit ac03d27d68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -149,8 +149,6 @@ export class Batch {
process(root_effects) {
queued_root_effects = [];
previous_batch = null;
this.apply();
/** @type {Effect[]} */
@ -168,14 +166,18 @@ export class Batch {
// log_inconsistent_branches(root);
}
if (!this.is_fork) {
this.#resolve();
}
if (this.is_deferred()) {
this.#defer_effects(render_effects);
this.#defer_effects(effects);
} else {
// append/remove branches
for (const fn of this.#commit_callbacks) fn();
this.#commit_callbacks.clear();
if (this.#pending === 0) {
this.#commit();
}
// If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
// newly updated sources, which could lead to infinite loops when effects run over and over again.
previous_batch = this;
@ -328,18 +330,6 @@ export class Batch {
this.#discard_callbacks.clear();
}
#resolve() {
if (this.#blocking_pending === 0) {
// append/remove branches
for (const fn of this.#commit_callbacks) fn();
this.#commit_callbacks.clear();
}
if (this.#pending === 0) {
this.#commit();
}
}
#commit() {
// If there are other pending batches, they now need to be 'rebased' —
// in other words, we re-run block/async effects with the newly

Loading…
Cancel
Save