adding default capacities to avoid lots of initial runtime resizing

pull/5/head
Evan Hemsley 2019-12-05 17:07:06 -08:00
parent 65e5ea2ec0
commit c11b5720b7
6 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,7 @@ namespace Encompass
{
internal class ComponentStore
{
private Dictionary<Type, TypedComponentStore> Stores = new Dictionary<Type, TypedComponentStore>();
private Dictionary<Type, TypedComponentStore> Stores = new Dictionary<Type, TypedComponentStore>(512);
public IEnumerable<(Type, TypedComponentStore)> StoresEnumerable()
{

View File

@ -15,8 +15,8 @@ namespace Encompass
internal class TypedComponentStore<TComponent> : TypedComponentStore where TComponent : struct, IComponent
{
private readonly Dictionary<Entity, TComponent> store = new Dictionary<Entity, TComponent>();
private readonly Dictionary<Entity, int> priorities = new Dictionary<Entity, int>();
private readonly Dictionary<Entity, TComponent> store = new Dictionary<Entity, TComponent>(128);
private readonly Dictionary<Entity, int> priorities = new Dictionary<Entity, int>(128);
public override int Count { get => store.Count; }

View File

@ -13,7 +13,7 @@ namespace Encompass
private readonly ComponentStore pendingComponentStore = new ComponentStore();
private ComponentStore upToDateComponentStore = new ComponentStore();
private readonly Dictionary<Type, Dictionary<Entity, int>> typeToEntityToPendingComponentPriority = new Dictionary<Type, Dictionary<Entity, int>>();
private readonly Dictionary<Type, Dictionary<Entity, int>> typeToEntityToPendingComponentPriority = new Dictionary<Type, Dictionary<Entity, int>>(128);
public ComponentStore UpToDateComponentStore { get => upToDateComponentStore; }

View File

@ -8,10 +8,10 @@ namespace Encompass
{
private readonly SortedList<int, int> layerOrder = new SortedList<int, int>();
private readonly Dictionary<int, ComponentStore> layerIndexToComponentStore = new Dictionary<int, ComponentStore>();
private readonly Dictionary<int, HashSet<GeneralRenderer>> layerIndexToGeneralRenderers = new Dictionary<int, HashSet<GeneralRenderer>>();
private readonly Dictionary<int, ComponentStore> layerIndexToComponentStore = new Dictionary<int, ComponentStore>(512);
private readonly Dictionary<int, HashSet<GeneralRenderer>> layerIndexToGeneralRenderers = new Dictionary<int, HashSet<GeneralRenderer>>(512);
private readonly Dictionary<Type, Dictionary<Entity, int>> typeToEntityToLayer = new Dictionary<Type, Dictionary<Entity, int>>();
private readonly Dictionary<Type, Dictionary<Entity, int>> typeToEntityToLayer = new Dictionary<Type, Dictionary<Entity, int>>(512);
public IEnumerable<int> LayerOrder { get { return layerOrder.Values; } }

View File

@ -7,9 +7,9 @@ namespace Encompass
{
internal class EntityManager
{
private readonly Dictionary<Guid, Entity> IDToEntity = new Dictionary<Guid, Entity>();
private readonly Dictionary<Guid, Entity> IDToEntity = new Dictionary<Guid, Entity>(1024);
private readonly HashSet<Entity> entitiesMarkedForDestroy = new HashSet<Entity>();
private readonly HashSet<Entity> entitiesMarkedForDestroy = new HashSet<Entity>(256);
private readonly ComponentManager componentManager;

View File

@ -10,7 +10,7 @@ namespace Encompass
private readonly DrawLayerManager drawLayerManager;
private readonly EntityManager entityManager;
private readonly Dictionary<Type, Action<Entity, IComponent>> drawComponentTypeToOrderedRenderer = new Dictionary<Type, Action<Entity, IComponent>>();
private readonly Dictionary<Type, Action<Entity, IComponent>> drawComponentTypeToOrderedRenderer = new Dictionary<Type, Action<Entity, IComponent>>(256);
public RenderManager(
ComponentManager componentManager,