Skip to content

Commit

Permalink
Pooling with reset for ComponentOperation & EntityOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
metaphore committed Jan 31, 2015
1 parent bfd5917 commit 356cf40
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ashley/src/com/badlogic/ashley/core/Engine.java
Expand Up @@ -476,7 +476,7 @@ public void remove(Entity entity, Class<? extends Component> componentClass) {
}
}

private static class ComponentOperation {
private static class ComponentOperation implements Pool.Poolable {
public enum Type {
Add,
Remove,
Expand All @@ -500,7 +500,13 @@ public void makeRemove(Entity entity, Class<? extends Component> componentClass)
this.component = null;
this.componentClass = componentClass;
}
}

@Override
public void reset() {
entity = null;
component = null;
}
}

private static class ComponentOperationPool extends Pool<ComponentOperation> {
@Override
Expand All @@ -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,
Expand All @@ -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<EntityOperation> {
@Override
Expand Down

0 comments on commit 356cf40

Please sign in to comment.