summaryrefslogtreecommitdiff
path: root/libjava/java/nio/FloatBuffer.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/nio/FloatBuffer.java')
-rw-r--r--libjava/java/nio/FloatBuffer.java43
1 files changed, 19 insertions, 24 deletions
diff --git a/libjava/java/nio/FloatBuffer.java b/libjava/java/nio/FloatBuffer.java
index 0c7b04dd0f5..ab87b7f898f 100644
--- a/libjava/java/nio/FloatBuffer.java
+++ b/libjava/java/nio/FloatBuffer.java
@@ -1,5 +1,5 @@
/* FloatBuffer.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -265,32 +265,27 @@ public abstract class FloatBuffer extends Buffer
*/
public int compareTo (Object obj)
{
- FloatBuffer a = (FloatBuffer) obj;
+ FloatBuffer other = (FloatBuffer) obj;
- if (a.remaining () != remaining ())
- return 1;
-
- if (! hasArray () ||
- ! a.hasArray ())
- {
- return 1;
- }
-
- int r = remaining ();
- int i1 = position ();
- int i2 = a.position ();
-
- for (int i = 0; i < r; i++)
+ int num = Math.min(remaining(), other.remaining());
+ int pos_this = position();
+ int pos_other = other.position();
+
+ for (int count = 0; count < num; count++)
{
- int t = (int) (get (i1) - a.get (i2));
-
- if (t != 0)
- {
- return (int) t;
- }
+ float a = get(pos_this++);
+ float b = other.get(pos_other++);
+
+ if (a == b)
+ continue;
+
+ if (a < b)
+ return -1;
+
+ return 1;
}
-
- return 0;
+
+ return remaining() - other.remaining();
}
/**