Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TrimExcess to TypeDictionary. #14900

Merged
merged 1 commit into from Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions OpenRA.Game/GameRules/ActorInfo.cs
Expand Up @@ -51,6 +51,8 @@ public ActorInfo(ObjectCreator creator, string name, MiniYaml node)
throw new YamlException(e.Message);
}
}

traits.TrimExcess();
}
catch (YamlException e)
{
Expand All @@ -63,6 +65,7 @@ public ActorInfo(string name, params ITraitInfo[] traitInfos)
Name = name;
foreach (var t in traitInfos)
traits.Add(t);
traits.TrimExcess();
}

static ITraitInfo LoadTraitInfo(ObjectCreator creator, string traitName, MiniYaml my)
Expand Down
6 changes: 6 additions & 0 deletions OpenRA.Game/Primitives/TypeDictionary.cs
Expand Up @@ -97,6 +97,12 @@ void InnerRemove(Type t, object val)
data.Remove(t);
}

public void TrimExcess()
{
foreach (var objs in data.Values)
objs.TrimExcess();
}

public IEnumerator GetEnumerator()
{
return WithInterface<object>().GetEnumerator();
Expand Down
2 changes: 2 additions & 0 deletions OpenRA.Game/Server/Server.cs
Expand Up @@ -140,6 +140,8 @@ public Server(IPEndPoint endpoint, ServerSettings settings, ModData modData, boo
foreach (var trait in modData.Manifest.ServerTraits)
serverTraits.Add(modData.ObjectCreator.CreateObject<ServerTrait>(trait));

serverTraits.TrimExcess();

LobbyInfo = new Session
{
GlobalSettings =
Expand Down