Simplify `MovieImporter.SingleSpaces`
This commit is contained in:
parent
759784a648
commit
ad8b4653d4
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue