Selectively TrimEnd without extra robust logic

TrimEnd has some loops and stuff which isn't necessary for single-char, single-time trims
This commit is contained in:
Kurt
2021-05-09 13:21:59 -07:00
parent 43af6322e8
commit f25ad054ef

View File

@@ -143,7 +143,14 @@ public static string[] LoadStringList(string file, string? txt)
return Array.Empty<string>();
string[] raw = txt.Split('\n');
for (int i = 0; i < raw.Length; i++)
raw[i] = raw[i].TrimEnd('\r');
{
var line = raw[i];
if (line.Length == 0)
continue;
var last = line.Length - 1;
if (line[last] == '\r')
raw[i] = line.Substring(0, last);
}
lock (getStringListLoadLock) // Make sure only one thread can write to the cache
{