Skip to content

Commit e2234d7

Browse files
Optimize updateCurveMenuItems in PathControlPointVisualiser
- Move totalCount calculation outside the loop as it is invariant. - Replace Where(predicate).Count(predicate) with a single Count(predicate) to reduce allocations.
1 parent fa3831d commit e2234d7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,11 @@ private void updateCurveMenuItems()
604604
if (curveTypeItems == null)
605605
return;
606606

607+
int totalCount = Pieces.Count(p => p.IsSelected.Value);
608+
607609
foreach (var item in curveTypeItems.OfType<CurveTypeMenuItem>())
608610
{
609-
int totalCount = Pieces.Count(p => p.IsSelected.Value);
610-
int countOfState = Pieces.Where(p => p.IsSelected.Value).Count(p => p.ControlPoint.Type == item.PathType);
611+
int countOfState = Pieces.Count(p => p.IsSelected.Value && p.ControlPoint.Type == item.PathType);
611612

612613
if (countOfState == totalCount)
613614
item.State.Value = TernaryState.True;

0 commit comments

Comments
 (0)