harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r658561 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
Date Wed, 21 May 2008 06:04:28 GMT
Author: lvjing
Date: Tue May 20 23:04:28 2008
New Revision: 658561

URL: http://svn.apache.org/viewvc?rev=658561&view=rev
Log:
Apply patch for HARMONY-5834, [classlib][luni] ArrayList growForInsert method code optimization

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java?rev=658561&r1=658560&r2=658561&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java Tue
May 20 23:04:28 2008
@@ -404,22 +404,16 @@
             increment = 12;
         }
         E[] newArray = newElementArray(size + increment);
-        if (location < size / 2) {
-            int newFirst = newArray.length - (size + required);
-            // Copy elements after location to the new array skipping inserted elements
-            System.arraycopy(array, location + firstIndex, newArray, location + increment,
-                    size - location);
-            // Copy elements before location to the new array from firstIndex
-            System.arraycopy(array, firstIndex, newArray, newFirst, location);
-            firstIndex = newFirst;
-            lastIndex = newArray.length;
-        } else {
-            System.arraycopy(array, firstIndex, newArray, 0, location);
-            System.arraycopy(array, location, newArray, location + required,
-                    size - location);
-            firstIndex = 0;
-            lastIndex += required;
-        }
+        int newFirst = increment - required;
+        // Copy elements after location to the new array skipping inserted
+        // elements
+        System.arraycopy(array, location + firstIndex, newArray, newFirst
+                + location + required, size - location);
+        // Copy elements before location to the new array from firstIndex
+        System.arraycopy(array, firstIndex, newArray, newFirst, location);
+        firstIndex = newFirst;
+        lastIndex = size + increment;
+
         array = newArray;
     }
 



Mime
View raw message