8000 Reduce allocations when `ModSelectOverlay` is visible by EVAST9919 · Pull Request #27366 · ppy/osu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

EVAST9919
Copy link
Contributor
master pr
master pr

@EVAST9919 EVAST9919 changed the title Reduce allocations when 'ModSelectOverlay' is visible Reduce allocations when ModSelectOverlay is visible Feb 24, 2024
float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X;
ShearedButton lastFooterButton = null!;

foreach (var b in footerButtonFlow)
Copy link
Member

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;
Copy link
Member

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.

Suggested change
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && allPanelsLoaded;
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && latestLoadedPanels?.All(static panel => panel.Parent != null) == true;

Copy link
Contributor Author
@EVAST9919 EVAST9919 Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well...
Снимок экрана 2024-02-26 203100

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)

@peppy peppy merged commit 7f0a552 into ppy:master Feb 27, 2024
@EVAST9919 EVAST9919 deleted the mod-overlay-performnce branch February 27, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0