From 3189323c2fce5fb9f588952ae987a985db4cdb1c Mon Sep 17 00:00:00 2001 From: Paul Speed Date: Sat, 5 Dec 2015 20:00:52 -0500 Subject: [PATCH] Converted manual array + list management over to just use SafeArrayList. It was a class added after this code. --- .../java/com/jme3/input/InputManager.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/input/InputManager.java b/jme3-core/src/main/java/com/jme3/input/InputManager.java index d3398c4f7..c430e267c 100644 --- a/jme3-core/src/main/java/com/jme3/input/InputManager.java +++ b/jme3-core/src/main/java/com/jme3/input/InputManager.java @@ -39,6 +39,7 @@ import com.jme3.math.FastMath; import com.jme3.math.Vector2f; import com.jme3.util.IntMap; import com.jme3.util.IntMap.Entry; +import com.jme3.util.SafeArrayList; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Level; @@ -97,15 +98,14 @@ public class InputManager implements RawInputListener { private boolean mouseVisible = true; private boolean safeMode = false; private float globalAxisDeadZone = 0.05f; - private Vector2f cursorPos = new Vector2f(); + private final Vector2f cursorPos = new Vector2f(); private Joystick[] joysticks; private final IntMap> bindings = new IntMap>(); private final HashMap mappings = new HashMap(); private final IntMap pressedButtons = new IntMap(); private final IntMap axisValues = new IntMap(); - private ArrayList rawListeners = new ArrayList(); - private RawInputListener[] rawListenerArray = null; - private ArrayList inputQueue = new ArrayList(); + private final SafeArrayList rawListeners = new SafeArrayList(RawInputListener.class); + private final ArrayList inputQueue = new ArrayList(); private static class Mapping { @@ -722,7 +722,6 @@ public class InputManager implements RawInputListener { */ public void addRawInputListener(RawInputListener listener) { rawListeners.add(listener); - rawListenerArray = null; } /** @@ -735,7 +734,6 @@ public class InputManager implements RawInputListener { */ public void removeRawInputListener(RawInputListener listener) { rawListeners.remove(listener); - rawListenerArray = null; } /** @@ -745,13 +743,6 @@ public class InputManager implements RawInputListener { */ public void clearRawInputListeners() { rawListeners.clear(); - rawListenerArray = null; - } - - private RawInputListener[] getRawListenerArray() { - if (rawListenerArray == null) - rawListenerArray = rawListeners.toArray(new RawInputListener[rawListeners.size()]); - return rawListenerArray; } /** @@ -814,7 +805,7 @@ public class InputManager implements RawInputListener { private void processQueue() { int queueSize = inputQueue.size(); - RawInputListener[] array = getRawListenerArray(); + RawInputListener[] array = rawListeners.getArray(); for (RawInputListener listener : array) { listener.beginInput();