Skip to content

Commit 2f7dc84

Browse files
ryansolidclaude
andauthored
perf(web): first-mount fast path inside reconcileArrays (#4297)
Alternative to #4294 at +59 B minified instead of +167 B: the empty-old-list case returns before the diff's setup, keeping the shared focus read. Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1 Co-authored-by: Claude <[email protected]>
1 parent 1d6c40f commit 2f7dc84

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/web": patch
3+
---
4+
5+
First mounts of a multi-node insert skip `reconcileArrays`' diff setup (spa-navigation mounts ~3%). The once-per-pass focus read from #4261 still applies, so a focused node arriving from another list keeps its focus.

‎packages/web/src/reconcile.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export default function reconcileArrays(parentNode: any, a: any[], b: any[], mar
2222
active && n.isConnected && n.contains(active)
2323
? parentNode.moveBefore(n, ref)
2424
: parentNode.insertBefore(n, ref);
25+
// First mount: skip the diff's setup, which cost spa-navigation mounts ~8%.
26+
if (!a.length) {
27+
for (const n of b) {
28+
insert(n, marker);
29+
if (marker) n[$$SLOT] = marker;
30+
}
31+
return;
32+
}
2533
// Ownership: an unclaimed node (no `$$SLOT`) is fair game; a tagged node
2634
// belongs only to the slot whose marker matches. `a[]` can name a node that
2735
// user code moved out of this parent (or into another slot of it); every

0 commit comments

Comments
 (0)