ta
TanStack
OSS
ta
Pipelines
Nx runs
Insights
Compare tasks
Analytics
Sign in
Toggle Sidebar
ro
router
Pipelines
perf(router-core): allocate replaceEqualDeep copies lazily `replaceEqualDeep` runs on every navigation and Link build: search, params, state and loader data all go through it, and in the common case `next` turns out to be deeply equal to `prev`. Until now the function still allocated the result object (or array) up front and filled it key by key while comparing, only to throw it away and return `prev`. The copy is now created at the first difference. Everything compared before that point is known to be equal and is taken from `prev` in one pass (`copyItems`), so unchanged subtrees are shared exactly as before. When nothing differs, nothing is allocated; when only the key sets differ, the copy is built after the loop. Smaller changes in the same function: - deep equality is a single `equal` flag instead of a matched-key count compared against the sizes afterwards; once unequal, the `hasOwn` check for keys that only `next` has is skipped - `nullReplaceEqualDeep` passes a boolean instead of an object factory, so the plain variant no longer evaluates a default `() => ({})` per call and the copy site has no indirect call - an overload signature keeps the generic return type without the `_next` alias in the emitted code - `getEnumerableOwnKeys` loops over `getOwnPropertySymbols` directly; an empty loop needs no early return `tests/replace-equal-deep.bench.ts` was added first, with the shapes the router feeds these helpers. Paired runs against the previous version (hz, 1000 calls per iteration): equal empty objects 10.0k -> 10.6k (+6%) equal flat search 5.3k -> 5.9k (+12%) equal nested search 2.2k -> 2.4k (+13%) equal array of objects 445 -> 485 (+9%) flat, one changed leaf 5.4k -> 5.2k (-3%) wide (12 keys) changed 2.4k -> 2.2k (-11%) The equal paths win and allocate nothing; the copy paths pay for the extra call and the per-key `copy` check.
nx affected --targets=test:eslint,test:unit,test:e2e,test:types,test:build,build --parallel=3
⌘K
perf(router-core): allocate replaceEqualDeep copies lazily
/
34825931611-1
Succeeded
in
10m 43s
Started
Copy command
nx affected --targets=test:eslint,test:unit,test:e2e,test:types,test:build,build --parallel=3
8362
8afdda2
GitHub
Open on GitHub
Tasks
Resource Usage
ta
TanStack
OSS