-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Reduce allocations when ModSelectOverlay
is visible
#27366
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
Conversation
master | pr |
---|---|
ModSelectOverlay
is visible
float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X; | ||
ShearedButton lastFooterButton = null!; | ||
|
||
foreach (var b in footerButtonFlow) |
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.
This is appalling legibility.
Surely we can at least use footerButtonFlow[^1]
.
private ICollection<ModPanel>? latestLoadedPanels; | ||
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && latestLoadedPanels?.All(panel => panel.Parent != null) == true; | ||
private ModPanel[]? latestLoadedPanels; | ||
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && allPanelsLoaded; |
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.
After switching to array, you should be able to use static predicate without allocs and avoid yawn methods.
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && allPanelsLoaded; | |
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && latestLoadedPanels?.All(static panel => panel.Parent != null) == 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.
And yes, I made sure I use static
.
That's another case of LINQ methods accepting IEnumerable
instead of provided type.
Same as in #27364 (comment)