-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Create a reverse map for faster itemBlock lookups #73930
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed in 0b711b4
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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