Index: src/main/java/java/util/ArrayList.java =================================================================== --- src/main/java/java/util/ArrayList.java (revision 658181) +++ src/main/java/java/util/ArrayList.java (working copy) @@ -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; }