Merge "Mark empty LocalVariableList as sorted"
am: d5c56fdb59

Change-Id: Icee32624919d549296d2a6f4c8b2fcb168be0236
diff --git a/dx/src/com/android/dx/util/FixedSizeList.java b/dx/src/com/android/dx/util/FixedSizeList.java
index 40fc90a..ad81363 100644
--- a/dx/src/com/android/dx/util/FixedSizeList.java
+++ b/dx/src/com/android/dx/util/FixedSizeList.java
@@ -36,6 +36,7 @@
      */
     public FixedSizeList(int size) {
         super(size != 0);
+        sorted = size == 0;
 
         try {
             arr = new Object[size];
@@ -278,11 +279,13 @@
 
     @SuppressWarnings("unchecked")
     protected <T> void sort(Comparator<T> comparator) {
-        throwIfImmutable();
+        if (!sorted) {
+            throwIfImmutable();
 
-        Arrays.<T>sort((T[]) arr, comparator);
-        setImmutable();
-        sorted = true;
+            Arrays.<T>sort((T[]) arr, comparator);
+            setImmutable();
+            sorted = true;
+        }
     }
 
     public boolean isSorted() {