[armedbear-cvs] r11986 - trunk/abcl/src/org/armedbear/lisp/util

Erik Huelsmann ehuelsmann at common-lisp.net
Mon Jun 1 21:02:48 UTC 2009


Author: ehuelsmann
Date: Mon Jun  1 17:02:33 2009
New Revision: 11986

Log:
Flush buffers sparingly.

Modified:
   trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java

Modified: trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java	Mon Jun  1 17:02:33 2009
@@ -403,15 +403,14 @@
 
     public final void position(long newPosition) throws IOException {
         flushBbuf();
-        long bbufend = bbufpos + // in case bbuf is readable, its contents is valid
-            bbufIsReadable ? bbuf.limit() : bbuf.position(); // beyond position()
+        long bbufend = bbufpos // in case bbuf is readable, its contents is valid
+            + (bbufIsReadable ? bbuf.limit() : bbuf.position()); // beyond position()
         if (newPosition >= bbufpos && newPosition < bbufend) {
             // near seek. within existing data of bbuf.
             bbuf.position((int)(newPosition - bbufpos));
         } else {
-            // far seek. discard the buffer.
-            flushBbuf();
             fcn.position(newPosition);
+            // far seek; discard the buffer (it's already cleared)
             bbuf.clear();
             bbuf.flip(); // "there is no useful data on this buffer yet."
             bbufpos = newPosition;
@@ -419,7 +418,6 @@
     }
 	
     public final long position() throws IOException {
-        flushBbuf();
         return bbufpos + bbuf.position(); // the logical position within the file.
     }
 




More information about the armedbear-cvs mailing list