updateBlockListSettings: convert state to Map, do all updates in one action#46392
updateBlockListSettings: convert state to Map, do all updates in one action#46392
Conversation
|
Size Change: +33 B (0%) Total Size: 7.74 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Hi, @jsnajdr Was there a reason we never implemented this change? I'm happy to take over if you still think there are some performance gains here. |
@Mamaduka I guess the performance tests didn't show the speed-up that I was hoping for. This PR want meant a follow-up to $46146 and #46204. These two PRs did similar object-to-map refactoring for other parts of state, and they had impact on the numbers. I think it's still a good idea to rebase this and try it again. If nothing else, it will be a nice refactoring that makes the codebase more consistent: use the same data structure for the same type of data. Not a random mix of objects and maps. |
|
Returning to this PR. I think it would be a nice addition to the recent improvements we're making for the Block Editor store. @jsnajdr, when you have time, do you mind rebasing and resolving merge conflicts? |
|
@Mamaduka Yes, I agree it's a good idea to convert the Another part that would be a very nice |
80fde67 to
851f1cd
Compare
|
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. |
851f1cd to
0f2ca41
Compare
| .filter( | ||
| ( [ , listSettings ] ) => | ||
| listSettings?.templateLock === 'contentOnly' | ||
| ) | ||
| .map( ( [ clientId ] ) => clientId ); |
There was a problem hiding this comment.
Do you think it's worth replacing similar filter/maps with something like - https://github.com/vercel-labs/agent-skills/blob/main/skills/react-best-practices/rules/js-flatmap-filter.md?
There was a problem hiding this comment.
Yes, I pushed a commit that implements this change. I've been thinking about flatMap, too, when seeing the updated code. But we don't use flatMap much, that's why I stayed with the classic filter/map initially.
There was a problem hiding this comment.
We start using it more. It's a nice pattern.
|
Flaky tests detected in 15669a0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24121521086
|
|
@jsnajdr, should we also update usage in |
9dde1ba to
15669a0
Compare
This is already done, isn't it? The original version of this PR from 2022 contained this change, but then it got done independently as part of #61329. We dispatch |
Converts the
state.blockListSettingsstate to aMap, hoping to make it faster. And when there are multiple pending updates for block list settings, do them inside oneupdateBlockListSettingsaction. That should be much faster thatregistry.batch(), because we're not creating a new state tree for the entire store for each update.