diff options
author | Per Bothner <per@bothner.com> | 2004-09-26 13:14:26 -0700 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2004-09-26 13:14:26 -0700 |
commit | a22478ced12a9b5f2bb59aad9be4e96528a9dcbe (patch) | |
tree | 41cad8cdf6ed43fb6b802fd8a2d50d2ca81b852f /libjava | |
parent | 87c476a22c6090159a3ab645561d9e1853af8d09 (diff) | |
download | gcc-a22478ced12a9b5f2bb59aad9be4e96528a9dcbe.zip gcc-a22478ced12a9b5f2bb59aad9be4e96528a9dcbe.tar.gz gcc-a22478ced12a9b5f2bb59aad9be4e96528a9dcbe.tar.bz2 |
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
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/util/Collections.java | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3bf4f1d..2a68a96 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2004-09-26 Per Bothner <per@bothner.com> + + * 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 <mark@klomp.org> * java/lang/System.java (properties): Make package private. diff --git a/libjava/java/util/Collections.java b/libjava/java/util/Collections.java index d50563c..d7b5e54 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]); } } |