You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by od...@apache.org on 2009/04/14 17:13:07 UTC

svn commit: r764822 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java

Author: odeakin
Date: Tue Apr 14 15:13:06 2009
New Revision: 764822

URL: http://svn.apache.org/viewvc?rev=764822&view=rev
Log:
Slight simplification of code - use BufferedInputStream instead of buffering the stream ourselves.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java?rev=764822&r1=764821&r2=764822&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java Tue Apr 14 15:13:06 2009
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.BufferedInputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintStream;
@@ -255,19 +256,14 @@
     public synchronized void load(InputStream in) throws IOException {
         int mode = NONE, unicode = 0, count = 0;
         char nextChar, buf[] = new char[40];
-        int offset = 0, keyLength = -1;
+        int offset = 0, keyLength = -1, intVal;
         boolean firstChar = true;
-        byte[] inbuf = new byte[256];
-        int inbufCount = 0, inbufPos = 0;
+        BufferedInputStream bis = new BufferedInputStream(in);
 
         while (true) {
-            if (inbufPos == inbufCount) {
-                if ((inbufCount = in.read(inbuf)) == -1) {
-                    break;
-                }
-                inbufPos = 0;
-            }
-            nextChar = (char) (inbuf[inbufPos++] & 0xff);
+            intVal = bis.read();
+            if (intVal == -1) break;
+            nextChar = (char) (intVal & 0xff);
 
             if (offset == buf.length) {
                 char[] newBuf = new char[buf.length * 2];
@@ -326,16 +322,11 @@
                 case '!':
                     if (firstChar) {
                         while (true) {
-                            if (inbufPos == inbufCount) {
-                                if ((inbufCount = in.read(inbuf)) == -1) {
-                                    inbufPos = -1;
-                                    break;
-                                }
-                                inbufPos = 0;
-                            }
-                            nextChar = (char) inbuf[inbufPos++]; // & 0xff
-                            // not
-                            // required
+                            intVal = bis.read();
+                            if (intVal == -1) break;
+                            nextChar = (char) intVal; // & 0xff
+                                                      // not
+                                                      // required
                             if (nextChar == '\r' || nextChar == '\n') {
                                 break;
                             }