Merge "Removed warning when objects are added on wrong order." into nyc-dev
diff --git a/core/java/android/util/ArraySet.java b/core/java/android/util/ArraySet.java
index d39e91f..1e765b6 100644
--- a/core/java/android/util/ArraySet.java
+++ b/core/java/android/util/ArraySet.java
@@ -402,11 +402,14 @@
             throw new IllegalStateException("Array is full");
         }
         if (index > 0 && mHashes[index - 1] > hash) {
-            RuntimeException e = new RuntimeException("here");
-            e.fillInStackTrace();
-            Log.w(TAG, "New hash " + hash
-                    + " is before end of array hash " + mHashes[index - 1]
-                    + " at index " + index, e);
+            // Cannot optimize since it would break the sorted order - fallback to add()
+            if (DEBUG) {
+                RuntimeException e = new RuntimeException("here");
+                e.fillInStackTrace();
+                Log.w(TAG, "New hash " + hash
+                        + " is before end of array hash " + mHashes[index - 1]
+                        + " at index " + index, e);
+            }
             add(value);
             return;
         }