Changeset 11986


Ignore:
Timestamp:
06/01/09 21:02:33 (12 years ago)
Author:
ehuelsmann
Message:

Flush buffers sparingly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java

    r11985 r11986  
    404404    public final void position(long newPosition) throws IOException {
    405405        flushBbuf();
    406         long bbufend = bbufpos + // in case bbuf is readable, its contents is valid
    407             bbufIsReadable ? bbuf.limit() : bbuf.position(); // beyond position()
     406        long bbufend = bbufpos // in case bbuf is readable, its contents is valid
     407            + (bbufIsReadable ? bbuf.limit() : bbuf.position()); // beyond position()
    408408        if (newPosition >= bbufpos && newPosition < bbufend) {
    409409            // near seek. within existing data of bbuf.
    410410            bbuf.position((int)(newPosition - bbufpos));
    411411        } else {
    412             // far seek. discard the buffer.
    413             flushBbuf();
    414412            fcn.position(newPosition);
     413            // far seek; discard the buffer (it's already cleared)
    415414            bbuf.clear();
    416415            bbuf.flip(); // "there is no useful data on this buffer yet."
     
    420419 
    421420    public final long position() throws IOException {
    422         flushBbuf();
    423421        return bbufpos + bbuf.position(); // the logical position within the file.
    424422    }
Note: See TracChangeset for help on using the changeset viewer.