Create a reverse map for faster itemBlock lookups#73930
Conversation
|
Size Change: +15 B (0%) Total Size: 2.58 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 0b711b4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20199102920
|
There was a problem hiding this comment.
With all the "mocking," there's probably little value in unit tests here, IMO. I think we have decent e2e test coverage. If something is missing, let's try to improve it.
There was a problem hiding this comment.
do these hooks have coverage already (where)? do we have test coverage reports that tell us what is or isn't covered?
There was a problem hiding this comment.
Usually, it's preferred to write e2e tests, unless the utility methods are complex. Besides components and data packages, you won't see a lot of unit tests.
|
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. |
Mamaduka
left a comment
There was a problem hiding this comment.
Thank you, @adamsilverstein!
What?
Improves performance of useBlockComments when there are many notes by replacing an O(n²) nested loop with an O(n) direct lookup. Previously, the code used Object.keys().find() to locate block client IDs for each comment thread, resulting in a search through all blocks for every thread. This change creates a reverse mapping (commentIdToBlockClientId) from comment IDs to block client IDs once, then performs constant-time lookups instead.
Part of #71668