-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Performance: Improve opening inserter in post editor #57006
Conversation
Size Change: +87 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
if ( ! inserter ) { | ||
return false; | ||
} | ||
const { blocks } = __experimentalGetParsedPattern( |
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.
I see we're still parsing patterns, but not all of them, but only until .some
detects one of them as allowed. Is that the optimization?
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.
Yes, that's it and in most cases we parse just the first pattern.
Flaky tests detected in eb576e9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7192803009
|
* Performance: Improve opening inserter in post editor * make selector private
What?
This PR improves the performance when opening the main inserter in post editor by introducing a new selector to check if we have at least one available allowed pattern. The new selector does exactly what the
__experimentalGetAllowedPatterns
does, but doesn't need to parse all patterns and of course returns a boolean value.In my profiling the tasks from
~116ms
is down to~6ms
.Notes for follow ups
Testing Instructions