1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 05:22:54 +08:00

Avoid redundant IndexOf calls

This commit is contained in:
Dean Herbert 2017-12-18 07:58:34 +09:00
parent 482941b333
commit c10288541c

View File

@ -54,7 +54,7 @@ namespace osu.Game.Screens.Select.Carousel
public override void AddChild(CarouselItem i)
{
base.AddChild(i);
updateSelectedIndex();
attemptSelection();
}
protected override void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
@ -99,6 +99,6 @@ namespace osu.Game.Screens.Select.Carousel
updateSelectedIndex();
}
private void updateSelectedIndex() => lastSelectedIndex = Math.Max(0, InternalChildren.IndexOf(lastSelected));
private void updateSelectedIndex() => lastSelectedIndex = lastSelected == null ? 0 : Math.Max(0, InternalChildren.IndexOf(lastSelected));
}
}