changeset 7811:e74b9d1d2785

copying elements outside the sublist view is redundant for sort Contributed-by: david.holmes@oracle.com
author akhil
date Thu, 04 Apr 2013 10:16:22 -0700
parents f262ed449eb4
children 026f882400f9
files src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
diffstat 1 files changed, 0 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Apr 04 11:38:48 2013 +0200
+++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Apr 04 10:16:22 2013 -0700
@@ -1460,14 +1460,8 @@
     private void sort(Comparator<? super E> c, final int from, final int to) {
         final E[] elements = (E[]) getArray();
         final E[] newElements = Arrays.copyOf(elements, elements.length);
-        for (int i = 0; i < from; i++) {
-            newElements[i] = elements[i];
-        }
         // only elements [from, to) are sorted
         Arrays.sort(newElements, from, to, c);
-        for (int i = to; i < elements.length; i++) {
-            newElements[i] = elements[i];
-        }
         setArray(newElements);
     }