From 56067b0077074c026b8ad099a74292a2becd6278 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 27 Jun 2000 21:27:50 +0000 Subject: [PATCH] PushbackInputStream.java (read): If there are characters in the buffer, don't also call super.read(). * java/io/PushbackInputStream.java (read): If there are characters in the buffer, don't also call super.read(). * java/io/PushbackReader.java (read): If there are characters in the buffer, don't also call super.read(). From-SVN: r34745 --- libjava/ChangeLog | 5 +++++ libjava/java/io/PushbackInputStream.java | 14 ++++++++------ libjava/java/io/PushbackReader.java | 12 ++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ba0d8586dd3..cb6fc869f9b 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,10 @@ 2000-06-27 Tom Tromey + * java/io/PushbackInputStream.java (read): If there are characters + in the buffer, don't also call super.read(). + * java/io/PushbackReader.java (read): If there are characters in + the buffer, don't also call super.read(). + * java/lang/Double.java (valueOf): Call parseDouble(). 2000-06-26 Warren Levy diff --git a/libjava/java/io/PushbackInputStream.java b/libjava/java/io/PushbackInputStream.java index c104cf2f407..537e1dbec57 100644 --- a/libjava/java/io/PushbackInputStream.java +++ b/libjava/java/io/PushbackInputStream.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000 Free Software Foundation This file is part of libgcj. @@ -70,12 +70,14 @@ public class PushbackInputStream extends FilterInputStream throw new ArrayIndexOutOfBoundsException(); int numBytes = Math.min(buf.length - pos, len); - for (int i = 0; i < numBytes; i++) - b[off++] = buf[pos++]; + if (numBytes > 0) + { + System.arraycopy (buf, pos, b, off, numBytes); + pos += numBytes; + return numBytes; + } - // `off' was just incremented to include `numBytes', so we can - // just pass ithere. - return numBytes + super.read(b, off, len - numBytes); + return super.read(b, off, len); } public void unread(int b) throws IOException diff --git a/libjava/java/io/PushbackReader.java b/libjava/java/io/PushbackReader.java index d5d8d441258..1a7523d0d15 100644 --- a/libjava/java/io/PushbackReader.java +++ b/libjava/java/io/PushbackReader.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000 Free Software Foundation This file is part of libgcj. @@ -79,10 +79,14 @@ public class PushbackReader extends FilterReader throw new ArrayIndexOutOfBoundsException(); int numBytes = Math.min(buf.length - pos, len); - for (int i = 0; i < numBytes; i++) - b[off++] = buf[pos++]; + if (numBytes > 0) + { + System.arraycopy (buf, pos, b, off, numBytes); + pos += numBytes; + return numBytes; + } - return numBytes + super.read(b, off, len - numBytes); + return super.read(b, off, len); } }