-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
peppy
commented
Sep 4, 2024
Before | After |
---|---|
public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Enumerable.Empty<DrawableCarouselItem>() : beatmapContainer.AliveChildren; | ||
|
||
private Container<DrawableCarouselItem>? beatmapContainer; | ||
public Container<DrawableCarouselItem>? Beatmaps; |
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.
I think I'd prefer this to be private and exposed as an IReadOnlyList
.
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.
Just to confirm, this means using the for
loop as you proposed?
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.
63b0368
to
dfe11dc
Compare
@@ -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; |
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.
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
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 it seemed fine. Worst case it's just setting some values when not required, but it's worth the alloc saving.