-
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
Refactor the block-editor "tree" state to use maps instead of objects #46229
Conversation
Size Change: +145 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
5f2ae6d
to
cab111a
Compare
29af52d
to
cae5e46
Compare
@@ -91,6 +91,18 @@ function flattenBlocks( blocks, transform = identity ) { | |||
return result; | |||
} | |||
|
|||
function getFlattenedClientIds( blocks ) { |
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.
If this function is called many times, and is worth a performance improvement, I think avoiding the stack array and the array operations and simply having a recursive function navigating the inner blocks tree is more performant.
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.
Actually no, a recursive function is in general less performant than the stacked alternative.
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 👍
Similar to #46204 #46221 #46225 and #46146
Following a similar approach to the previous PRs, I tried to see how refactoring the parents state from plain objects to maps could impact the performance. Here are the results I got:
Before:
After: