1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Use StringSplitOptions.TrimEntries for string.Split() when possible

This commit is contained in:
Berkan Diler 2022-12-27 09:41:58 +01:00
parent 38a674cd84
commit 182f36c434
2 changed files with 5 additions and 11 deletions

View File

@ -45,7 +45,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
continue;
// ReSharper disable once PossibleNullReferenceException
string[] split = line.Split(':');
string[] split = line.Split(':', StringSplitOptions.TrimEntries);
if (split.Length < 2)
{
@ -55,9 +55,9 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
teams.Add(new TournamentTeam
{
FullName = { Value = split[1].Trim(), },
Acronym = { Value = split.Length >= 3 ? split[2].Trim() : null, },
FlagName = { Value = split[0].Trim() }
FullName = { Value = split[1], },
Acronym = { Value = split.Length >= 3 ? split[2] : null, },
FlagName = { Value = split[0] }
});
}
}

View File

@ -132,13 +132,7 @@ namespace osu.Game.Beatmaps.Formats
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':', bool shouldTrim = true)
{
string[] split = line.Split(separator, 2);
if (shouldTrim)
{
for (int i = 0; i < split.Length; i++)
split[i] = split[i].Trim();
}
string[] split = line.Split(separator, 2, shouldTrim ? StringSplitOptions.TrimEntries : StringSplitOptions.None);
return new KeyValuePair<string, string>
(