chore: make `batch.#pending` a number rather than a map (#18184)

there's no reason for this to be a map
pull/18186/head
Rich Harris 4 months ago committed by GitHub
parent 1c150a460f
commit 4d2b6c61e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -130,10 +130,9 @@ export class Batch {
#fork_commit_callbacks = new Set(); #fork_commit_callbacks = new Set();
/** /**
* Async effects that are currently in flight * The number of async effects that are currently in flight
* @type {Map<Effect, number>}
*/ */
#pending = new Map(); #pending = 0;
/** /**
* Async effects that are currently in flight, _not_ inside a pending boundary * Async effects that are currently in flight, _not_ inside a pending boundary
@ -327,7 +326,7 @@ export class Batch {
reset_branch(e, t); reset_branch(e, t);
} }
} else { } else {
if (this.#pending.size === 0) { if (this.#pending === 0) {
batches.delete(this); batches.delete(this);
} }
@ -637,8 +636,7 @@ export class Batch {
* @param {Effect} effect * @param {Effect} effect
*/ */
increment(blocking, effect) { increment(blocking, effect) {
let pending_count = this.#pending.get(effect) ?? 0; this.#pending += 1;
this.#pending.set(effect, pending_count + 1);
if (blocking) { if (blocking) {
let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0; let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
@ -652,13 +650,7 @@ export class Batch {
* @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction) * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
*/ */
decrement(blocking, effect, skip) { decrement(blocking, effect, skip) {
let pending_count = this.#pending.get(effect) ?? 0; this.#pending -= 1;
if (pending_count === 1) {
this.#pending.delete(effect);
} else {
this.#pending.set(effect, pending_count - 1);
}
if (blocking) { if (blocking) {
let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0; let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;

Loading…
Cancel
Save