Skip to content

Commit

Permalink
Avoid using .Children for enumeration in other locations
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 22, 2024
1 parent 069af13 commit 02bb506
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 19 deletions.
13 changes: 6 additions & 7 deletions osu.Desktop.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
"osu.Game.Tournament.Tests\\osu.Game.Tournament.Tests.csproj",
"osu.Game.Tournament\\osu.Game.Tournament.csproj",
"osu.Game\\osu.Game.csproj",

"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform.Tests\\osu.Game.Rulesets.EmptyFreeform.Tests.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling\\osu.Game.Rulesets.EmptyScrolling.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling.Tests\\osu.Game.Rulesets.EmptyScrolling.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj"
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling\\osu.Game.Rulesets.EmptyScrolling.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj"
]
}
}
}
4 changes: 2 additions & 2 deletions osu.Game/Graphics/Containers/WaveContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public WaveContainer()

protected override void PopIn()
{
foreach (var w in wavesContainer.Children)
foreach (var w in wavesContainer)
w.Show();

contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
Expand All @@ -132,7 +132,7 @@ protected override void PopIn()

protected override void PopOut()
{
foreach (var w in wavesContainer.Children)
foreach (var w in wavesContainer)
w.Hide();

contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Graphics/UserInterface/BreadcrumbControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public BreadcrumbControl()

Current.ValueChanged += index =>
{
foreach (var t in TabContainer.Children.OfType<BreadcrumbTabItem>())
foreach (var t in TabContainer.OfType<BreadcrumbTabItem>())
{
int tIndex = TabContainer.IndexOf(t);
int tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Graphics/UserInterface/OsuTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public virtual Color4 AccentColour

if (Dropdown is IHasAccentColour dropdown)
dropdown.AccentColour = value;
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
foreach (var i in TabContainer.OfType<IHasAccentColour>())
i.AccentColour = value;
}
}
Expand All @@ -48,7 +48,7 @@ public virtual Color4 AccentColour

protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);

protected virtual float StripWidth => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
protected virtual float StripWidth => TabContainer.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;

/// <summary>
/// Whether entries should be automatically populated if <typeparamref name="T"/> is an <see cref="Enum"/> type.
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Graphics/UserInterface/StarCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void ReplayAnimation()
public void StopAnimation()
{
animate(current);
foreach (var star in stars.Children)
foreach (var star in stars)
star.FinishTransforms(true);
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Chat/Listing/ChannelListing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void UpdateAvailableChannels(IEnumerable<Channel> newChannels)
flow.ChildrenEnumerable = newChannels.Where(c => c.Type == ChannelType.Public)
.Select(c => new ChannelListingItem(c));

foreach (var item in flow.Children)
foreach (var item in flow)
{
item.OnRequestJoin += channel => OnRequestJoin?.Invoke(channel);
item.OnRequestLeave += channel => OnRequestLeave?.Invoke(channel);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Overlays/OverlayStreamControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ protected override TabItem<T> CreateTabItem(T value) => CreateStreamItem(value).

protected override bool OnHover(HoverEvent e)
{
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
foreach (var streamBadge in TabContainer.OfType<OverlayStreamItem<T>>())
streamBadge.UserHoveringArea = true;

return base.OnHover(e);
}

protected override void OnHoverLost(HoverLostEvent e)
{
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
foreach (var streamBadge in TabContainer.OfType<OverlayStreamItem<T>>())
streamBadge.UserHoveringArea = false;

base.OnHoverLost(e);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Menu/ButtonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public ButtonSystemState State
{
buttonArea.ButtonSystemState = state;

foreach (var b in buttonArea.Children.OfType<MainMenuButton>())
foreach (var b in buttonArea.OfType<MainMenuButton>())
b.ButtonSystemState = state;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override void LoadComplete()
CounterFlow.Direction = convertedDirection;
foreach (var counter in CounterFlow.Children)
foreach (var counter in CounterFlow)
counter.Direction.Value = convertedDirection;
}, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private void updateBeatmapYPositions()

bool isSelected = Item?.State.Value == CarouselItemState.Selected;

foreach (var panel in beatmapContainer.Children)
foreach (var panel in beatmapContainer)
{
Debug.Assert(panel.Item != null);

Expand Down

0 comments on commit 02bb506

Please sign in to comment.