From 8405fdcc4f0398ae53deb783b97776e7bd06d06c Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 07:38:34 -0400 Subject: [PATCH] more NaN check business --- core/src/processing/data/FloatDict.java | 3 +++ core/src/processing/data/FloatList.java | 4 ++++ 2 files changed, 7 insertions(+) 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]) {