-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocks: Don't memoize 'hasContentRoleAttribute' selector #65617
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find @Mamaduka 👍
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just use Object.values
if we are not interested in the keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 9a1273f.
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 🚢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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 <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: getdave <[email protected]>
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: getdave <[email protected]>
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
hasContentRoleAttribute
selector.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.