Merge pull request #3265 from smoogipoo/storyboard-hotpath

Slightly improve performance of beatmap/storyboard parsing
This commit is contained in:
Dean Herbert
2018-08-21 12:10:37 +09:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ namespace osu.Game.Beatmaps.Formats
if (ShouldSkipLine(line)) if (ShouldSkipLine(line))
continue; continue;
if (line.StartsWith(@"[") && line.EndsWith(@"]")) if (line.StartsWith(@"[", StringComparison.Ordinal) && line.EndsWith(@"]", StringComparison.Ordinal))
{ {
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section)) if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
{ {
@ -53,7 +53,7 @@ namespace osu.Game.Beatmaps.Formats
} }
} }
protected virtual bool ShouldSkipLine(string line) => string.IsNullOrWhiteSpace(line) || line.StartsWith("//"); protected virtual bool ShouldSkipLine(string line) => string.IsNullOrWhiteSpace(line) || line.StartsWith("//", StringComparison.Ordinal);
protected virtual void ParseLine(T output, Section section, string line) protected virtual void ParseLine(T output, Section section, string line)
{ {

View File

@ -60,7 +60,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleEvents(string line) private void handleEvents(string line)
{ {
var depth = 0; var depth = 0;
while (line.StartsWith(" ") || line.StartsWith("_")) while (line.StartsWith(" ", StringComparison.Ordinal) || line.StartsWith("_", StringComparison.Ordinal))
{ {
++depth; ++depth;
line = line.Substring(1); line = line.Substring(1);