From: Per Bothner Date: Sun, 26 Sep 2004 20:14:26 +0000 (-0700) Subject: Collections.java (sort): Copy from array in forwards order... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a22478ced12a9b5f2bb59aad9be4e96528a9dcbe;p=gcc.git Collections.java (sort): Copy from array in forwards order... * java/util/Collections.java (sort): Copy from array in forwards order, rather than reverse order which may be much less efficient. From-SVN: r88146 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3bf4f1d1e1a..2a68a967f57 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2004-09-26 Per Bothner + + * java/util/Collections.java (sort): Copy from array in forwards + order, rather than reverse order which may be much less efficient. + 2004-09-26 Mark Wielaard * java/lang/System.java (properties): Make package private. diff --git a/libjava/java/util/Collections.java b/libjava/java/util/Collections.java index d50563c9022..d7b5e54e4a8 100644 --- a/libjava/java/util/Collections.java +++ b/libjava/java/util/Collections.java @@ -1713,11 +1713,11 @@ public class Collections { Object[] a = l.toArray(); Arrays.sort(a, c); - ListIterator i = l.listIterator(a.length); - for (int pos = a.length; --pos >= 0; ) + ListIterator i = l.listIterator(); + for (int pos = 0, alen = a.length; pos < alen; pos++) { - i.previous(); - i.set(a[pos]); + i.next(); + i.set(a[pos]); } }