Skip to content

Commit af4b69a

Browse files
authored
Merge pull request #2751 from mizulu/pref-reconcile-remove-redundent-keyFn-call
Perf | remove redundent call to keyFn(state).
2 parents c83e9a2 + 0564da2 commit af4b69a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Avoid recomputing reconcile state identity keys.

packages/solid-signals/src/store/reconcile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export function reconcile<T extends U, U>(
363363
if (state == null) throw new Error("Cannot reconcile null or undefined state");
364364
const keyFn = typeof key === "string" ? item => item[key] : key;
365365
const eq = keyFn(state);
366-
if (eq !== undefined && keyFn(value) !== keyFn(state))
366+
if (eq !== undefined && keyFn(value) !== eq)
367367
throw new Error("Cannot reconcile states with different identity");
368368
applyState(value, state, keyFn);
369369
};

0 commit comments

Comments
 (0)