Skip to content

Commit afb074b

Browse files
refactor(signals): trim the F5 and #3796 fixes' minified cost
The lane-leave condition reads as one negation ("unless created, errored, read the lane, or a guess"), and the chained-draft resolution is one expression. No behavior change. Co-authored-by: Cursor <[email protected]>
1 parent 8b581d7 commit afb074b

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎packages/signals/src/core/lanes.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export function laneStage(
308308
create: boolean,
309309
errored: boolean
310310
): boolean {
311-
if (!create && !errored && !(el._flags & REACTIVE_LANE_READ) && !(el._config & CONFIG_GUESS)) {
311+
if (!(create || errored || el._flags & REACTIVE_LANE_READ || el._config & CONFIG_GUESS)) {
312312
if (el._x !== null) {
313313
if (el._x._transaction?._lane) el._x._transaction = null;
314314
el._x._lane = NOT_PENDING;

‎packages/signals/src/store/optimistic.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ export function notifyOptimisticWrites(
119119
// A chained draft holds the inner store's raws; a raw is the inner slot it
120120
// resolves to (as a read of it serves) — the row a held write staged is
121121
// the same row, not a guess over the slot (#3796).
122-
let nv = pb[key as any];
123-
if (inner && nv) nv = resolveChainedRaw(t, key, nv);
124-
nv = unwrapValue(nv);
122+
const raw = pb[key as any];
123+
const nv = unwrapValue(inner && raw ? resolveChainedRaw(t, key, raw) : raw);
125124
if (!(key in old)) {
126125
guess(getNode(t, key), key, false, nv);
127126
guess(getHasNode(t, key), key, true, true);

0 commit comments

Comments
 (0)