From 0b2ef556342f54e91e86890add5a76b9ec7a02ae Mon Sep 17 00:00:00 2001 From: thatcosmonaut Date: Wed, 17 Jul 2019 18:56:02 -0700 Subject: [PATCH] reverse lookup optimization --- encompass-cs/ComponentManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/encompass-cs/ComponentManager.cs b/encompass-cs/ComponentManager.cs index 50fb6d1..9f6ca8d 100644 --- a/encompass-cs/ComponentManager.cs +++ b/encompass-cs/ComponentManager.cs @@ -11,10 +11,10 @@ namespace Encompass private readonly Dictionary componentIDToType = new Dictionary(); private readonly Dictionary IDToComponent = new Dictionary(); - private readonly Dictionary> entityIDToComponentIDs = new Dictionary>(); // TODO: hashset + private readonly Dictionary> entityIDToComponentIDs = new Dictionary>(); private readonly Dictionary componentIDToEntityID = new Dictionary(); - private readonly Dictionary> typeToComponentIDs = new Dictionary>(); // TODO: hashset + private readonly Dictionary> typeToComponentIDs = new Dictionary>(); private readonly List activeComponents = new List(); private readonly List inactiveComponents = new List(); @@ -42,7 +42,7 @@ namespace Encompass internal void RegisterEntity(Guid entityID) { - entityIDToComponentIDs.Add(entityID, new List()); + entityIDToComponentIDs.Add(entityID, new HashSet()); } internal Guid AddComponent(Guid entityID, TComponent component) where TComponent : struct, IComponent @@ -54,7 +54,7 @@ namespace Encompass if (!typeToComponentIDs.ContainsKey(typeof(TComponent))) { - typeToComponentIDs.Add(typeof(TComponent), new List()); + typeToComponentIDs.Add(typeof(TComponent), new HashSet()); } typeToComponentIDs[typeof(TComponent)].Add(componentID);