Avoid string allocations in MiniYaml parsing.

- Stream lines in as memory rather than needing to realise a string for each line, via a new method in StreamExts.
- Use span to avoid string allocations during parsing until we want to realise the node itself, in MiniYaml.FromLines.
- Change several callsites to use the streaming extension method rather than string method where possible.
This commit is contained in:
RoosterDragon
2021-10-10 12:41:54 +01:00
committed by abcdefg30
parent 270c566570
commit 0f01df5474
9 changed files with 165 additions and 42 deletions

View File

@@ -183,9 +183,9 @@ namespace OpenRA
try
{
var httpResponseMessage = await client.GetAsync(url);
var result = await httpResponseMessage.Content.ReadAsStringAsync();
var result = await httpResponseMessage.Content.ReadAsStreamAsync();
var yaml = MiniYaml.FromString(result);
var yaml = MiniYaml.FromStream(result);
foreach (var kv in yaml)
previews[kv.Key].UpdateRemoteSearch(MapStatus.DownloadAvailable, kv.Value, mapDetailsReceived);