From 3bdf82d8df16ed910920c56938c3a74811a49602 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Tue, 28 Nov 2017 21:38:11 +0100 Subject: [PATCH] refactor newly added code to be less redundant --- osu.Game/Screens/Select/BeatmapCarousel.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index e0f3137cec..3f42ae11ac 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -124,23 +124,18 @@ namespace osu.Game.Screens.Select // todo: this method should be smarter as to not recreate panels that haven't changed, etc. var group = groups.Find(b => b.BeatmapSet.ID == set.ID); - BeatmapGroup newGroup; - if (group == null) - { - newGroup = createGroup(set); - - if (newGroup != null) - groups.Add(newGroup); - } - else - { - int i = groups.IndexOf(group); + int i = groups.IndexOf(group); + if (i >= 0) groups.RemoveAt(i); - newGroup = createGroup(set); + var newGroup = createGroup(set); - if (newGroup != null) + if (newGroup != null) + { + if (i >= 0) groups.Insert(i, newGroup); + else + groups.Add(newGroup); } bool hadSelection = selectedGroup == group;