mirror of
https://github.com/ppy/osu
synced 2024-12-13 18:37:04 +00:00
Merge pull request #7768 from turbedi/string_cleanup
Minor cleanups for legacy beatmap decoders
This commit is contained in:
commit
c7ef15f6cf
@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
|
||||
protected override bool ShouldSkipLine(string line) => base.ShouldSkipLine(line) || line.StartsWith(" ", StringComparison.Ordinal) || line.StartsWith("_", StringComparison.Ordinal);
|
||||
protected override bool ShouldSkipLine(string line) => base.ShouldSkipLine(line) || line.StartsWith(' ') || line.StartsWith('_');
|
||||
|
||||
protected override void ParseLine(Beatmap beatmap, Section section, string line)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
if (ShouldSkipLine(line))
|
||||
continue;
|
||||
|
||||
if (line.StartsWith(@"[", StringComparison.Ordinal) && line.EndsWith(@"]", StringComparison.Ordinal))
|
||||
if (line.StartsWith('[') && line.EndsWith(']'))
|
||||
{
|
||||
if (!Enum.TryParse(line[1..^1], out section))
|
||||
{
|
||||
|
@ -64,15 +64,16 @@ namespace osu.Game.Beatmaps.Formats
|
||||
private void handleEvents(string line)
|
||||
{
|
||||
var depth = 0;
|
||||
var lineSpan = line.AsSpan();
|
||||
|
||||
while (lineSpan.StartsWith(" ", StringComparison.Ordinal) || lineSpan.StartsWith("_", StringComparison.Ordinal))
|
||||
foreach (char c in line)
|
||||
{
|
||||
lineSpan = lineSpan.Slice(1);
|
||||
++depth;
|
||||
if (c == ' ' || c == '_')
|
||||
depth++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
line = lineSpan.ToString();
|
||||
line = line.Substring(depth);
|
||||
|
||||
decodeVariables(ref line);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user