You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 44da46e
Browse filesBrowse the repository at this point in the historyBrowse files
perf(signals,web,universal): source kinds decided once at view build; no brand check per read
A read through merge(defaults, store) was 1.5x slower than next: the walk
was the same (in, then get) but went through sourceHas/sourceGet, each
starting with `s instanceof OmitView` — on a store proxy that is a
getPrototypeOf trap (~20 ns, as much as the read itself), twice per read.
spread()'s per-key walk over a store-backed view paid the same.
Every source entry now carries its kind (plain / omit record / proxy /
memo), decided in merge()'s flattening loop and omit()'s argument check
where the information already exists (MergeView.kinds, OmitView.kind).
mergeGet/has/descriptor/ownKeys and the consumers (spread in web and
universal, ssrElement) switch on the kind; the exported entry helpers take
it as a parameter. viewOf(o) hands consumers the record behind a merge or
omit proxy in two fast traps.
Table-backed views also cache their own-keys array and per-key descriptor
shape, so an enumeration through the traps re-reads no leaf descriptor.
merge(defaults, store) 84 ns -> 61 ns (next -> branch)
merge(defaults, store) + 5 reads 404 ns -> 346 ns (was 635 before this)
merge(defaults, store) every key 2081 ns -> 1824 ns (was 3149)
omit(store, 5) every key 1470 ns -> 1287 ns
Object.keys(omit(store, 5)) 6979 ns -> 5417 ns
A trap-logging store-shaped proxy pins it: a read through a merge or omit
asks the store exactly what a direct read would.
Co-authored-by: Cursor <[email protected]>
Copy file name to clipboardExpand all lines: .changeset/merge-omit-lazy-views.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ The two compose flat. An `omit()` over a `merge()` carries one filtered view per
14
14
15
15
Reads stay cheap: a view over plain objects resolves a key → owning-leaf table once, on first read, and every `get`/`has`/descriptor is one lookup after that. `spread()` (DOM and universal) and `ssrElement()` read the leaves directly — never through the proxies' traps — and walk that table when there is one, so an effect rerun costs one read per key, as it did over the copy. Both proxies use a class target and one shared handler (no per-instance closures).
16
16
17
+
A view over a store asks the store nothing but the read. Each source's kind (plain object, omit record, proxy, memo) is decided once, when the view is built, and carried beside it — every brand check on a Proxy is a trap (`instanceof` is a `getPrototypeOf` trap, as expensive as a store read), and store detection goes through `$TARGET`, a symbol the store's `get` trap answers on its fast path, never its generic tracked-read path. `merge(defaults, store)` constructs ~30% faster than the copy did and reads ~15% faster; `omit(store)` reads at parity.
18
+
17
19
The views tell the truth: `Object.getOwnPropertyDescriptor(view, key)` reports a data descriptor only when the key is a data property of a plain leaf (the compiler's encoding of a static prop) and an accessor for a getter, a store key, or a memo source. Together with the new internal `hasStaticKeys()`, `spread()` now skips the children effect for static children behind `omit`/`merge` layers (#3388 through views).
18
20
19
21
Behavior changes:
@@ -24,4 +26,4 @@ Behavior changes:
24
26
- Sources are treated as own-keyed; a key added to a plain source after merging is not seen (the copy did not see it either).
25
27
- Enumerating a view through its traps (`for…in`, `Object.keys`, `{ ...view }`) costs a trap per key, as any proxy does; the internal consumers avoid it. Environments without `Proxy` keep the copy paths.
26
28
27
-
Internal helpers for consumers, exported from `solid-js`: `omitView(o)`, `sourceKeys(entry)`, `sourceHas(entry, key)`, `sourceGet(entry, key)`, `hasStaticKeys(o)`, `resolvedTable(o)`.
29
+
Internal helpers for consumers, exported from `solid-js`: `viewOf(o)`, `mergeView(o)`, `omitView(o)`, `sourceKeys(entry, kind)`, `sourceHas(entry, kind, key)`, `sourceGet(entry, kind, key)`, `hasStaticKeys(o)`, `resolvedTable(o)`, the `SOURCE_*` kinds.
0 commit comments