Use string pooling in MiniYaml to de-duplicate strings in memory.

These config files often contain many repeated strings which result in different string references in memory. By using a pool, we can detect when the strings are equal and reuse an existing reference as strings are immutable.

The FromLines will now use a pool to de-duplicate strings for a single call. By allowing a pool to be provided as a parameter, we can reuse even more strings. The MapCache defines such a pool so that strings are reused across all maps in the cache for even more savings.
This commit is contained in:
RoosterDragon
2020-10-11 12:13:37 +01:00
committed by abcdefg30
parent 9072d645fd
commit 8fb65fd9bf
4 changed files with 25 additions and 9 deletions

View File

@@ -38,6 +38,8 @@ namespace OpenRA
object syncRoot = new object();
Queue<MapPreview> generateMinimap = new Queue<MapPreview>();
public Dictionary<string, string> StringPool { get; } = new Dictionary<string, string>();
public MapCache(ModData modData)
{
this.modData = modData;