-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
UI materials: don't reserve in loop when enough capacity #15919
UI materials: don't reserve in loop when enough capacity #15919
Conversation
transparent_phase | ||
.items | ||
.reserve(extracted_uinodes.uinodes.len()); | ||
if transparent_phase.items.capacity() < extracted_uinodes.uinodes.len() { |
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.
The transparent phase items vec is shared between all the extracted UI items, not just uimaterial nodes, so this isn't quite right either. Maybe the current length of items needs to be stored before the start of the loop, then this condition could become transparent_phase.items.capacity() - initial_len < extracted.uinodes.len()
?
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.
so it seems we have no way to know the exact size required on each transparent phase, as not all nodes may go to the same if there are several cameras
Current behaviour on main is that for each entity, it's reserving "number of entities" capacity, so this PR is still an improvement
instead of:
- for each entity
- ensure phase can store "number of entities" more items <- allocate for every pass through the loop
- push to the phase
it does:
- for each entity
- ensure once that phase can store "number of entities" more items <- allocate once
- push to the phase <- allocate once capacity has been reached for every pass through the loop
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.
Yeah that makes sense. We can merge this and look for further improvements later.
Objective
Solution