diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index eef136d45..ec6fd9bd0 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -671,6 +671,9 @@ public class FloatDict { if (useKeys) { return count; // don't worry about NaN values + } else if (count == 0) { // skip the NaN check, it'll AIOOBE + return 0; + } else { // first move NaN values to the end of the list int right = count - 1; while (values[right] != values[right]) { diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 7be02fcc1..dd050e111 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -566,6 +566,10 @@ public class FloatList implements Iterable { new Sort() { @Override public int size() { + // if empty, don't even mess with the NaN check, it'll AIOOBE + if (count == 0) { + return 0; + } // move NaN values to the end of the list and don't sort them int right = count - 1; while (data[right] != data[right]) {