-
Notifications
You must be signed in to change notification settings - Fork 774
Optimized UI Drawing #8139
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
base: gui-next
Are you sure you want to change the base?
Optimized UI Drawing #8139
Conversation
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.
Nothing bad just some minor comments about performance pet peeves. Great work!
panels.render(bgLayer, 0, 0xffffffff); | ||
|
||
// Allow all composite widgets to participate in the sprite layer | ||
widgets.drawBackgroundSpriteLayer(bgLayer, getBounds(true), new Point(mouseX - leftPos, mouseY - topPos)); |
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.
There's only one mouse and creation of new unmanaged objects like a new Point
is not really necessary is it?
var background = style.getBackground(); | ||
if (background != null) { | ||
background.dest(offsetX, offsetY).blit(guiGraphics); | ||
widgets.addBackgroundPanels(panels, getBounds(true)); |
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.
Store the result of getBounds
- excessive cyclic calls are also ill advised as this is used not even 2 lines later.
|
||
// Group all slots by semantic. We make the assumption here | ||
// that visually the slots belonging to the same semantic are contiguous. | ||
for (var semantic : menu.getSlotBySemantic().keySet()) { |
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.
Store the menu.getSlotBySemantic()
as a local variable (lv
) as per the aforementioned advice. it's used a lot and recursive calls are still ill advised.
maxY = Math.max(maxY, backgroundY + backgroundHeight); | ||
} | ||
|
||
for (var slot : slots) { |
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.
Is two iterations necessary? Couldn't this pass be done in the previous loop on line 795 and again at line 824? The control flow graph only shows those 2 branch points? Also it's generally bad practice to separate alterations and work as it loses context of where/when it was modified.
Plus you do the exact same instanceof
and isActive
logic in the aforementioned loop already... Why make it do double work - especially considering that aside from object creation (new
) instanceof
is the most costly java dynamic.
No description provided.