1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 17:13:06 +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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -35,14 +34,7 @@ namespace osu.Game.Screens.Play.HUD
public LocalisableString Text public LocalisableString Text
{ {
get => textPart.Text; get => textPart.Text;
set set => textPart.Text = value;
{
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;
}
} }
public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null) 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) private string textLookup(char c)