Simplify `MovieImporter.SingleSpaces`

This commit is contained in:
YoshiRulz 2024-07-03 19:43:24 +10:00
parent 759784a648
commit ad8b4653d4
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 4 additions and 14 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using BizHawk.Common;
@ -122,22 +123,11 @@ namespace BizHawk.Client.Common
return str.Trim();
}
private static readonly Regex WhitespacePattern = new(@"\s+");
// Reduce all whitespace to single spaces.
protected static string SingleSpaces(string line)
{
line = line.Replace("\t", " ");
line = line.Replace("\n", " ");
line = line.Replace("\r", " ");
line = line.Replace("\r\n", " ");
string prev;
do
{
prev = line;
line = line.Replace(" ", " ");
}
while (prev != line);
return line;
}
=> WhitespacePattern.Replace(line, " ");
// Ends the string where a NULL character is found.
protected static string NullTerminated(string str)