-
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
Block Editor: Improve empty getBlockParents()
perf
#48242
Conversation
Size Change: +5 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 8879f41. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4230137482
|
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.
Looks good 👍
There is, however, nothing special about empty array here, is it? Even for non-empty parent arrays, the selector will often return a new array although its contents didn't change. Any change in |
42fd67e
to
8879f41
Compare
Yeah, that's fair to say, but since the reducer works with maps, it would be a completely separate optimization. It would be worth to see if it's being called often enough to require optimization in the first place. |
What?
This PR improves the performance of the
getBlockParents()
selector, so it will always return the same empty array if no parents are returned.Why?
I've noticed that when the List View is opened, and we're moving with the arrows up and down, extra re-renders are caused because
getBlockParents()
returns a different empty array every time.How?
We're simply returning the same empty array when the selector would return an empty array.
Testing Instructions
Testing Instructions for Keyboard
None
Screenshots or screencast
None