You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by lv...@apache.org on 2008/05/21 08:04:28 UTC
svn commit: r658561 -
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ArrayList.java
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;
}