Skip to content
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

Fix per-frame allocations in BeatmapCarousel #29688

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

peppy
Copy link
Member

@peppy peppy commented Sep 4, 2024

Before After
JetBrains Rider 2024-09-04 at 04 54 23 JetBrains Rider 2024-09-04 at 05 31 06

public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Enumerable.Empty<DrawableCarouselItem>() : beatmapContainer.AliveChildren;

private Container<DrawableCarouselItem>? beatmapContainer;
public Container<DrawableCarouselItem>? Beatmaps;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd prefer this to be private and exposed as an IReadOnlyList.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to confirm, this means using the for loop as you proposed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah.

@pull-request-size pull-request-size bot added size/S and removed size/M labels Sep 4, 2024
@bdach bdach self-requested a review September 4, 2024 07:40
@peppy peppy added the next release Pull requests which are almost there. We'll aim to get them in the next release, but no guarantees! label Sep 4, 2024
@@ -51,7 +51,7 @@ public partial class DrawableCarouselBeatmapSet : DrawableCarouselItem, IHasCont
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } = null!;

public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Enumerable.Empty<DrawableCarouselItem>() : beatmapContainer.AliveChildren;
public IReadOnlyList<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Array.Empty<DrawableCarouselItem>() : beatmapContainer;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't immediately tell if the AliveChildren to Children swap here is correct but I don't think we do any lifetime games in song select so I think it should be

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it seemed fine. Worst case it's just setting some values when not required, but it's worth the alloc saving.

@smoogipoo smoogipoo merged commit 337a30f into ppy:master Sep 4, 2024
11 of 13 checks passed
@peppy peppy deleted the fix-song-select-allocs branch September 5, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next release Pull requests which are almost there. We'll aim to get them in the next release, but no guarantees! size/S type:performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants