Add TrimExcess to TypeDictionary.
After adding is finished, this can be used to reduce the memory footprint of the dictionary.
This commit is contained in:
@@ -51,6 +51,8 @@ namespace OpenRA
|
|||||||
throw new YamlException(e.Message);
|
throw new YamlException(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
traits.TrimExcess();
|
||||||
}
|
}
|
||||||
catch (YamlException e)
|
catch (YamlException e)
|
||||||
{
|
{
|
||||||
@@ -63,6 +65,7 @@ namespace OpenRA
|
|||||||
Name = name;
|
Name = name;
|
||||||
foreach (var t in traitInfos)
|
foreach (var t in traitInfos)
|
||||||
traits.Add(t);
|
traits.Add(t);
|
||||||
|
traits.TrimExcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ITraitInfo LoadTraitInfo(ObjectCreator creator, string traitName, MiniYaml my)
|
static ITraitInfo LoadTraitInfo(ObjectCreator creator, string traitName, MiniYaml my)
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ namespace OpenRA.Primitives
|
|||||||
data.Remove(t);
|
data.Remove(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TrimExcess()
|
||||||
|
{
|
||||||
|
foreach (var objs in data.Values)
|
||||||
|
objs.TrimExcess();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
public IEnumerator GetEnumerator()
|
||||||
{
|
{
|
||||||
return WithInterface<object>().GetEnumerator();
|
return WithInterface<object>().GetEnumerator();
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ namespace OpenRA.Server
|
|||||||
foreach (var trait in modData.Manifest.ServerTraits)
|
foreach (var trait in modData.Manifest.ServerTraits)
|
||||||
serverTraits.Add(modData.ObjectCreator.CreateObject<ServerTrait>(trait));
|
serverTraits.Add(modData.ObjectCreator.CreateObject<ServerTrait>(trait));
|
||||||
|
|
||||||
|
serverTraits.TrimExcess();
|
||||||
|
|
||||||
LobbyInfo = new Session
|
LobbyInfo = new Session
|
||||||
{
|
{
|
||||||
GlobalSettings =
|
GlobalSettings =
|
||||||
|
|||||||
Reference in New Issue
Block a user