1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 12:23:13 +08:00

Make use of ElementAtOrDefault() when possible

This commit is contained in:
Berkan Diler 2020-01-31 18:32:47 +01:00
parent f736bbfccb
commit 9596030e1d
4 changed files with 4 additions and 4 deletions

View File

@ -321,7 +321,7 @@ namespace osu.Game.Overlays
private void selectTab(int index) private void selectTab(int index)
{ {
var channel = ChannelTabControl.Items.Skip(index).FirstOrDefault(); var channel = ChannelTabControl.Items.ElementAtOrDefault(index);
if (channel != null && !(channel is ChannelSelectorTabItem.ChannelSelectorTabChannel)) if (channel != null && !(channel is ChannelSelectorTabItem.ChannelSelectorTabChannel))
ChannelTabControl.Current.Value = channel; ChannelTabControl.Current.Value = channel;
} }

View File

@ -196,7 +196,7 @@ namespace osu.Game.Overlays
if (!instant) if (!instant)
queuedDirection = TrackChangeDirection.Next; queuedDirection = TrackChangeDirection.Next;
var playable = BeatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).Skip(1).FirstOrDefault() ?? BeatmapSets.FirstOrDefault(); var playable = BeatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).ElementAtOrDefault(1) ?? BeatmapSets.FirstOrDefault();
if (playable != null) if (playable != null)
{ {

View File

@ -99,7 +99,7 @@ namespace osu.Game.Overlays.Toolbar
{ {
int requested = e.Key - Key.Number1; int requested = e.Key - Key.Number1;
RulesetInfo found = Rulesets.AvailableRulesets.Skip(requested).FirstOrDefault(); RulesetInfo found = Rulesets.AvailableRulesets.ElementAtOrDefault(requested);
if (found != null) if (found != null)
Current.Value = found; Current.Value = found;
return true; return true;

View File

@ -154,7 +154,7 @@ namespace osu.Game.Rulesets.Edit
{ {
if (e.Key >= Key.Number1 && e.Key <= Key.Number9) if (e.Key >= Key.Number1 && e.Key <= Key.Number9)
{ {
var item = toolboxCollection.Items.Skip(e.Key - Key.Number1).FirstOrDefault(); var item = toolboxCollection.Items.ElementAtOrDefault(e.Key - Key.Number1);
if (item != null) if (item != null)
{ {