Skip to content

Commit 842e3bd

Browse files
committed
perf(signals): the #4536 hook reuses store's linkedTo and reads the render effect's own pending flag
Drops the hook's own walk of the derive's subscribers (store.ts's `linkedTo` already is one) and its `_pendingSources` lookup: a render effect is pending, the list view carries the #4525 mark, and guesses stand. About 68 B minified off the store-family rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent 25a05b4 commit 842e3bd

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import {
6161
getHasNode,
6262
getNode,
6363
LaneView,
64+
linkedTo,
6465
resolveChainedRaw,
6566
sameKey,
6667
storeSetter,
@@ -600,11 +601,11 @@ installOptHooks({
600601
const c: any = context;
601602
if (!o?.size || (a === clock + 1 && passLane === null && !o.has(t)) || a === ~clock)
602603
return false;
603-
for (let s = d._subs; s; s = s._nextSub) if (s._sub === c) return false;
604+
if (linkedTo(c, d)) return false;
604605
if (
605606
(t.k?._x?._lane as LaneView)?.g === null &&
606607
c?._type === EFFECT_RENDER &&
607-
c._x?._pendingSources?.has(d)
608+
c._statusFlags & STATUS_PENDING
608609
)
609610
readNode(d);
610611
return true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ function serveDataKey(
18381838

18391839
/** Is `c` among `n`'s subscribers (any pass's link — a kept tail included)?
18401840
* `n`'s subs, not `c`'s deps: the derive's are its few flight observers. */
1841-
function linkedTo(c: Computed<any>, n: Signal<any>): boolean {
1841+
export function linkedTo(c: Computed<any>, n: Signal<any>): boolean {
18421842
for (let s = n._subs; s !== null; s = s._nextSub) if (s._sub === c) return true;
18431843
return false;
18441844
}

0 commit comments

Comments
 (0)