1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:43:22 +08:00

Avoid completely unnecessary string allocations in ArgonCounterTextComponent

This commit is contained in:
Dean Herbert 2024-01-07 13:10:50 +09:00
parent 5cc4a586ac
commit 16ea7f9b77
No known key found for this signature in database

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -35,14 +34,7 @@ namespace osu.Game.Screens.Play.HUD
public LocalisableString Text
{
get => textPart.Text;
set
{
int remainingCount = RequiredDisplayDigits.Value - value.ToString().Count(char.IsDigit);
string remainingText = remainingCount > 0 ? new string('#', remainingCount) : string.Empty;
wireframesPart.Text = remainingText + value;
textPart.Text = value;
}
set => textPart.Text = value;
}
public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null)
@ -83,6 +75,8 @@ namespace osu.Game.Screens.Play.HUD
}
}
};
RequiredDisplayDigits.BindValueChanged(digits => wireframesPart.Text = new string('#', digits.NewValue));
}
private string textLookup(char c)