chore: remove stale_readers

The dedupe isn't needed for any test, including async-stale-read-multiple-no-double-run.
async-another-try-pt-1-prune
Rich Harris 16 hours ago
parent 4d65c92b96
commit b60c1b23de
No known key found for this signature in database

@ -129,21 +129,6 @@ export class Batch {
*/ */
merged_into = null; merged_into = null;
/**
* @type {Set<Reaction> | null}
*/
#stale_readers = null;
/**
* Reactions that, while running in an earlier batch, read a value that this batch holds
* a newer version of, and that are therefore scheduled to re-run in this batch. Used to
* avoid scheduling the same reaction multiple times when it reads more than one such value.
* Lazily initialized for performance reasons.
*/
get stale_readers() {
return (this.#stale_readers ??= new Set());
}
/** @type {Batch | null} */ /** @type {Batch | null} */
prev = null; prev = null;

@ -764,27 +764,18 @@ function get_batch_value(signal, first_time) {
(active_effect !== null && active_reaction === active_effect && (active_effect.f & REACTION_IS_UPDATING) !== 0) || (active_effect !== null && active_reaction === active_effect && (active_effect.f & REACTION_IS_UPDATING) !== 0) ||
(active_effect !== null && (active_effect.f & ASYNC) !== 0); (active_effect !== null && (active_effect.f & ASYNC) !== 0);
if ( if (reader !== null && reactive) {
reader !== null &&
reactive &&
// a reaction can read several stale values in one run — only schedule the re-run once
!batch.stale_readers.has(reader)
) {
batch.stale_readers.add(reader);
if (current.is_eager) { if (current.is_eager) {
// Reactions of eager effects with at least one non-eager effect (which we know is true here due to the stale_sources check above) // Reactions of eager effects with at least one non-eager effect (which we know is true here due to the stale_sources check above)
// need to rerun because they could do something like `$state.eager(count) !== count`. // need to rerun because they could do something like `$state.eager(count) !== count`.
if (reader.deps?.some((dep) => dep.f & EAGER_EFFECT)) { if (reader.deps?.some((dep) => dep.f & EAGER_EFFECT)) {
batch.oncommit(() => { batch.oncommit(() => {
batch.stale_readers.delete(reader);
Batch.ensure(); Batch.ensure();
invalidate(reader, DIRTY); invalidate(reader, DIRTY);
}); });
} }
} else { } else {
queue_micro_task(() => { queue_micro_task(() => {
batch.stale_readers.delete(reader);
const b = batch.activate(); const b = batch.activate();
invalidate(reader, MAYBE_DIRTY); invalidate(reader, MAYBE_DIRTY);
b.flush(); b.flush();

Loading…
Cancel
Save