mirror of
https://github.com/ppy/osu
synced 2024-12-27 17:32:56 +00:00
Merge pull request #10532 from turbedi/minor_string_optimization
Use char overloads for string methods
This commit is contained in:
commit
74bee65474
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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])
|
||||
|
@ -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);
|
||||
|
@ -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 =>
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user