Reuse buffers when loading Xcc databases.

We can reuse the list as a buffer when reading strings to avoid throwaway allocations, which will reduce GC pressure during loading.
This commit is contained in:
RoosterDragon
2017-11-17 19:39:15 +00:00
committed by Pavel Penev
parent c48ddbdfa5
commit 6a97502e09
2 changed files with 4 additions and 2 deletions

View File

@@ -28,15 +28,16 @@ namespace OpenRA.Mods.Cnc.FileFormats
while (s.Peek() > -1)
{
var count = s.ReadInt32();
var chars = new List<char>();
for (var i = 0; i < count; i++)
{
var chars = new List<char>();
byte c;
// Read filename
while ((c = s.ReadUInt8()) != 0)
chars.Add((char)c);
entries.Add(new string(chars.ToArray()));
chars.Clear();
// Skip comment
while ((c = s.ReadUInt8()) != 0) { }