From 5d7413f19c7a9f888d68fec6acc9086b43d967e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 17 Dec 2017 04:30:56 +0900 Subject: [PATCH] Improve performance with large numbers of panels visible --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- .../Select/Carousel/CarouselGroupEagerSelect.cs | 12 ++++++++++++ osu.Game/Screens/Select/Carousel/CarouselItem.cs | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index dac01f788c..459d364f73 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -483,11 +483,11 @@ namespace osu.Game.Screens.Select { DrawableCarouselItem item = Items[i]; + if (!item.Item.Visible) continue; + // Only add if we're not already part of the content. if (!scrollableContent.Contains(item)) { - if (!item.Item.Visible) continue; - // Makes sure headers are always _below_ items, // and depth flows downward. item.Depth = i + (item is DrawableCarouselBeatmapSet ? -Items.Count : 0); diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs index 2d79742cc8..65282542e6 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs @@ -27,9 +27,19 @@ namespace osu.Game.Screens.Select.Carousel private CarouselItem lastSelected; + /// + /// To avoid overhead during filter operations, we don't attempt any selections until after all + /// children have been filtered. This bool will be true during the base + /// operation. + /// + private bool filteringChildren; + public override void Filter(FilterCriteria criteria) { + filteringChildren = true; base.Filter(criteria); + filteringChildren = false; + attemptSelection(); } @@ -64,6 +74,8 @@ namespace osu.Game.Screens.Select.Carousel private void attemptSelection() { + if (filteringChildren) return; + // we only perform eager selection if we are a currently selected group. if (State != CarouselItemState.Selected) return; diff --git a/osu.Game/Screens/Select/Carousel/CarouselItem.cs b/osu.Game/Screens/Select/Carousel/CarouselItem.cs index b7c5227414..c289481d16 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselItem.cs @@ -33,7 +33,8 @@ namespace osu.Game.Screens.Select.Carousel if (InternalChildren != null) foreach (var c in InternalChildren) - items.AddRange(c.Drawables); + // if (!c.Filtered) <- potential optimisation at the cost of no fade out animations. + items.AddRange(c.Drawables); return items; }