core-data: Memoize getEntitiesConfig
selector
#58393
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
This PR suggests memoizing the
getEntitiesConfig()
config selector. Spotted while reviewing some other PRs.cc @jsnajdr and @ellatrix as I know they've been working to optimize some selectors (and remove some needlessly memoized ones).
Why?
Because it will return a new array on every call (only because
.filter()
returns a new array), and in many cases, that's wasteful, as the underlying data hasn't changed. Cases like this are some of the reasons why we're memoizing selectors in the first place.In my testing, this reduces the selector calls by 5 times during a standard site editor load. Then a few more calls are completely removed when opening the inserter. I don't see substantial improvements in the performance test results, but the more different entities are requested, the better the improvement will be.
How?
We're straightforwardly using
createSelector()
.Testing Instructions
Verify all checks are green - this is well covered by tests.
Testing Instructions for Keyboard
None
Screenshots or screencast
None