1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 19:27:26 +08:00

Merge pull request #10532 from turbedi/minor_string_optimization

Use char overloads for string methods
This commit is contained in:
Dean Herbert 2020-10-16 19:36:39 +09:00 committed by GitHub
commit 74bee65474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 13 additions and 13 deletions

View File

@ -98,7 +98,7 @@ namespace osu.Game.Beatmaps
[JsonIgnore]
public string StoredBookmarks
{
get => string.Join(",", Bookmarks);
get => string.Join(',', Bookmarks);
set
{
if (string.IsNullOrEmpty(value))

View File

@ -593,7 +593,7 @@ namespace osu.Game.Database
var fileInfos = new List<TFileModel>();
string prefix = reader.Filenames.GetCommonPrefix();
if (!(prefix.EndsWith("/", StringComparison.Ordinal) || prefix.EndsWith("\\", StringComparison.Ordinal)))
if (!(prefix.EndsWith('/') || prefix.EndsWith('\\')))
prefix = string.Empty;
// import files to manager

View File

@ -196,7 +196,7 @@ namespace osu.Game.Online.Chat
if (target == null)
return;
var parameters = text.Split(new[] { ' ' }, 2);
var parameters = text.Split(' ', 2);
string command = parameters[0];
string content = parameters.Length == 2 ? parameters[1] : string.Empty;

View File

@ -111,7 +111,7 @@ namespace osu.Game.Online.Chat
public static LinkDetails GetLinkDetails(string url)
{
var args = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
var args = url.Split('/', StringSplitOptions.RemoveEmptyEntries);
args[0] = args[0].TrimEnd(':');
switch (args[0])

View File

@ -181,7 +181,7 @@ namespace osu.Game
if (args?.Length > 0)
{
var paths = args.Where(a => !a.StartsWith(@"-", StringComparison.Ordinal)).ToArray();
var paths = args.Where(a => !a.StartsWith('-')).ToArray();
if (paths.Length > 0)
Task.Run(() => Import(paths));
}
@ -289,7 +289,7 @@ namespace osu.Game
public void OpenUrlExternally(string url) => waitForReady(() => externalLinkOpener, _ =>
{
if (url.StartsWith("/", StringComparison.Ordinal))
if (url.StartsWith('/'))
url = $"{API.Endpoint}{url}";
externalLinkOpener.OpenUrlExternally(url);

View File

@ -148,7 +148,7 @@ namespace osu.Game.Overlays.Profile.Header
if (string.IsNullOrEmpty(content)) return false;
// newlines could be contained in API returned user content.
content = content.Replace("\n", " ");
content = content.Replace('\n', ' ');
bottomLinkContainer.AddIcon(icon, text =>
{

View File

@ -159,7 +159,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
{
string[] ss = split[5].Split(':');
endTime = Math.Max(startTime, Parsing.ParseDouble(ss[0]));
readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo);
readCustomSampleBanks(string.Join(':', ss.Skip(1)), bankInfo);
}
result = CreateHold(pos, combo, comboOffset, endTime + Offset - startTime);

View File

@ -80,9 +80,9 @@ namespace osu.Game.Screens.Select
private static int getLengthScale(string value) =>
value.EndsWith("ms", StringComparison.Ordinal) ? 1 :
value.EndsWith("s", StringComparison.Ordinal) ? 1000 :
value.EndsWith("m", StringComparison.Ordinal) ? 60000 :
value.EndsWith("h", StringComparison.Ordinal) ? 3600000 : 1000;
value.EndsWith('s') ? 1000 :
value.EndsWith('m') ? 60000 :
value.EndsWith('h') ? 3600000 : 1000;
private static bool parseFloatWithPoint(string value, out float result) =>
float.TryParse(value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);

View File

@ -18,6 +18,6 @@ namespace osu.Game.Skinning
protected virtual string ComponentName => Component.ToString();
public string LookupName =>
string.Join("/", new[] { "Gameplay", RulesetPrefix, ComponentName }.Where(s => !string.IsNullOrEmpty(s)));
string.Join('/', new[] { "Gameplay", RulesetPrefix, ComponentName }.Where(s => !string.IsNullOrEmpty(s)));
}
}

View File

@ -17,6 +17,6 @@ namespace osu.Game.Skinning
protected virtual string ComponentName => Component.ToString();
public string LookupName =>
string.Join("/", new[] { "HUD", ComponentName }.Where(s => !string.IsNullOrEmpty(s)));
string.Join('/', new[] { "HUD", ComponentName }.Where(s => !string.IsNullOrEmpty(s)));
}
}