From 356cf4097f7c870cccc67cffca62ff3f32f103da Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Sat, 31 Jan 2015 15:55:00 +0700 Subject: [PATCH] Pooling with reset for ComponentOperation & EntityOperation --- .../src/com/badlogic/ashley/core/Engine.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ashley/src/com/badlogic/ashley/core/Engine.java b/ashley/src/com/badlogic/ashley/core/Engine.java index 012ea076..95cae3b1 100644 --- a/ashley/src/com/badlogic/ashley/core/Engine.java +++ b/ashley/src/com/badlogic/ashley/core/Engine.java @@ -476,7 +476,7 @@ public void remove(Entity entity, Class componentClass) { } } - private static class ComponentOperation { + private static class ComponentOperation implements Pool.Poolable { public enum Type { Add, Remove, @@ -500,7 +500,13 @@ public void makeRemove(Entity entity, Class componentClass) this.component = null; this.componentClass = componentClass; } - } + + @Override + public void reset() { + entity = null; + component = null; + } + } private static class ComponentOperationPool extends Pool { @Override @@ -516,7 +522,7 @@ public int compare(EntitySystem a, EntitySystem b) { } } - private static class EntityOperation { + private static class EntityOperation implements Pool.Poolable { public enum Type { Add, Remove, @@ -525,7 +531,12 @@ public enum Type { public Type type; public Entity entity; - } + + @Override + public void reset() { + entity = null; + } + } private static class EntityOperationPool extends Pool { @Override