Improve YAML parse time.

Stream lines to avoid needing to load the whole file first, and avoid a LINQ Contains call when string.IndexOf will be much faster.
This commit is contained in:
RoosterDragon
2014-12-30 18:17:32 +00:00
parent 06226e8958
commit fdcfb30011
2 changed files with 8 additions and 18 deletions

View File

@@ -124,17 +124,10 @@ namespace OpenRA
public static IEnumerable<string> ReadAllLines(this Stream s)
{
string line;
using (var sr = new StreamReader(s))
{
for (;;)
{
var line = sr.ReadLine();
if (line == null)
yield break;
else
yield return line;
}
}
while ((line = sr.ReadLine()) != null)
yield return line;
}
// The string is assumed to be length-prefixed, as written by WriteString()