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

Remove constructor with preFill argument from Pool #6117

Merged
merged 2 commits into from Jul 24, 2020
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 CHANGES
@@ -1,3 +1,6 @@
[1.9.12]
- API Change: Removed Pool constructor with preFill parameter in favor of using Pool#fill() method. See #6117

[1.9.11]
- Update to MobiVM 2.3.8
- Update to LWJGL 3.2.3
Expand Down
5 changes: 0 additions & 5 deletions gdx/src/com/badlogic/gdx/graphics/g2d/ParticleEffectPool.java
Expand Up @@ -28,11 +28,6 @@ public ParticleEffectPool (ParticleEffect effect, int initialCapacity, int max)
this.effect = effect;
}

public ParticleEffectPool (ParticleEffect effect, int initialCapacity, int max, boolean preFill) {
super(initialCapacity, max, preFill);
this.effect = effect;
}

protected PooledEffect newObject () {
PooledEffect pooledEffect = new PooledEffect(effect);
pooledEffect.start();
Expand Down
4 changes: 0 additions & 4 deletions gdx/src/com/badlogic/gdx/utils/FlushablePool.java
Expand Up @@ -34,10 +34,6 @@ public FlushablePool (int initialCapacity, int max) {
super(initialCapacity, max);
}

public FlushablePool (int initialCapacity, int max, boolean preFill) {
super(initialCapacity, max, preFill);
}

@Override
public T obtain () {
T result = super.obtain();
Expand Down
23 changes: 5 additions & 18 deletions gdx/src/com/badlogic/gdx/utils/Pool.java
Expand Up @@ -29,33 +29,20 @@ abstract public class Pool<T> {

/** Creates a pool with an initial capacity of 16 and no maximum. */
public Pool () {
this(16, Integer.MAX_VALUE, false);
this(16, Integer.MAX_VALUE);
}

/** Creates a pool with the specified initial capacity and no maximum. */
public Pool (int initialCapacity) {
this(initialCapacity, Integer.MAX_VALUE, false);
this(initialCapacity, Integer.MAX_VALUE);
}

/** @param max The maximum number of free objects to store in this pool. */
/** @param initialCapacity The initial size of the array supporting the pool. No objects are created/pre-allocated.
* Use {@link #fill(int) after instantiation if needed.
* @param max The maximum number of free objects to store in this pool. */
public Pool (int initialCapacity, int max) {
this(initialCapacity, max, false);
}

/** @param initialCapacity The initial size of the array supporting the pool. No objects are created unless preFill is true.
* @param max The maximum number of free objects to store in this pool.
* @param preFill Whether to pre-fill the pool with objects. The number of pre-filled objects will be equal to the initial
* capacity. */
public Pool (int initialCapacity, int max, boolean preFill) {
if (initialCapacity > max && preFill)
throw new IllegalArgumentException("max must be larger than initialCapacity if preFill is set to true.");
freeObjects = new Array(false, initialCapacity);
this.max = max;
if (preFill) {
for (int i = 0; i < initialCapacity; i++)
freeObjects.add(newObject());
peak = freeObjects.size;
}
}

abstract protected T newObject ();
Expand Down
10 changes: 3 additions & 7 deletions gdx/src/com/badlogic/gdx/utils/ReflectionPool.java
Expand Up @@ -27,19 +27,15 @@ public class ReflectionPool<T> extends Pool<T> {
private final Constructor constructor;

public ReflectionPool (Class<T> type) {
this(type, 16, Integer.MAX_VALUE, false);
this(type, 16, Integer.MAX_VALUE);
}

public ReflectionPool (Class<T> type, int initialCapacity) {
this(type, initialCapacity, Integer.MAX_VALUE, false);
this(type, initialCapacity, Integer.MAX_VALUE);
}

public ReflectionPool (Class<T> type, int initialCapacity, int max) {
this(type, initialCapacity, max, false);
}

public ReflectionPool (Class<T> type, int initialCapacity, int max, boolean preFill) {
super(initialCapacity, max, preFill);
super(initialCapacity, max);
constructor = findConstructor(type);
if (constructor == null)
throw new RuntimeException("Class cannot be created (missing no-arg constructor): " + type.getName());
Expand Down