Blocks: Don't memoize 'hasContentRoleAttribute' selector#65617
Conversation
|
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. |
|
Size Change: -8 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
|
Why were we memoizing it then? |
It was introduced in #43037 and I don't see a good reason to do it. Perhaps to avoid looping through all the block type attributes on every run, but I don't foresee a performance issue with that. |
Not sure. It was introduced in #43037, and there are no notes about memoization. @jorgefilipecosta might remember more context. |
jsnajdr
left a comment
There was a problem hiding this comment.
Why not, the memoization is not particularly valuable here. If nothing else, it simplifies the code. Originally the createSelector call was probably added out of habit, simply because most other selectors also use it. Nothing bad about it.
| } | ||
|
|
||
| return Object.entries( blockType.attributes ).some( | ||
| ( [ , { role, __experimentalRole } ] ) => { |
There was a problem hiding this comment.
We can just use Object.values if we are not interested in the keys.
Only because of the reasons @Mamaduka stated (i.e. if there was no value why was it added in the first place?).
Makes sense and is understandable. Thanks all 🚢 |
|
Flaky tests detected in 9a1273f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11016459521
|
|
There was a conflict while trying to cherry-pick the commit to the wp/6.7 branch. Please resolve the conflict manually and create a PR to the wp/6.7 branch. PRs to wp/6.7 are similar to PRs to trunk, but you should base your PR on the wp/6.7 branch instead of trunk. |
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org>
|
Thank you for this change, yah memoization here does not make sense I think I included by mistake because the related selectors had it. |
What?
This is a follow-up to #65484.
PR removes memoization for the private
hasContentRoleAttributeselector.Why?
The selector returns primitive boolean values; there should be no need to memorize. It's hard to anticipate performance improvements for similar optimizations without real data like CodeVitals.
Testing Instructions
CI checks should be green.