Core Data: Remove redundant memoization wrapper from 'getQueriedItems'#77483
Conversation
|
Size Change: -22 B (0%) Total Size: 7.82 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in b3b0e0e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25095171228
|
jsnajdr
left a comment
There was a problem hiding this comment.
Makes sense, if createSelector doesn't have a getDependants argument, the default is to use dependants in the form:
[ [ state, query, options ] ]i.e., one-member deps array where the single member is the array of arguments. Including state, different array on each call. That doesn't make much sense.
|
|
||
| ## Unreleased | ||
|
|
||
| ### Enhancements |
There was a problem hiding this comment.
In packages where we really carefully maintain a changelog, like components or dataviews, this would be in the "Internal" section. "Enhancements" are usually user-visible new APIs and features.
There was a problem hiding this comment.
I was debating this myself. I'll change the section title.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Drop the `createSelector` (rememo) wrapper around `getQueriedItems`; keep the existing inner `EquivalentKeyMap`-based cache.
4c2518a to
b3b0e0e
Compare

What?
This is a follow-up to #76406 (comment).
Drop the
createSelector(rememo) wrapper aroundgetQueriedItems; keep the existing innerEquivalentKeyMap-based cache.Why?
Rememo caches by reference equality on arguments. Callers inline query objects (
getEntityRecords(state, 'postType', 'post', { per_page: 10 })), so the query is a new reference every call and rememo's cache never hits - every call fell through to the inner function.The inner
EquivalentKeyMapcaches by deep equality, which is how queries are actually passed. Removing the wrapper keeps behavior identical and drops per-call overhead (arg copy, WeakMap walk, linked-list scan).Testing Instructions
useSelecthook, which tests unstable references in dev mode.Testing Instructions for Keyboard
Same.