The outer loop (while (remaining > 0)) doesn't make sense since the decrements
at the end are wrong anyway; it just works if the whole block is read on the
first file.read(b). This outer loop appears to be a leftover from the original
JDBM implementation.
Besides, there's no need to pass in the nBytes parameter; the RecordFile class
creates BlockIos always with an array of BLOCK_SIZE bytes, and thus the
RecordFile class can rely on this fact and just use buffer.length.
Attached is a rewritten RecordFile.read(). Use or don't use as you like; if you
do, also omit the last parameter in the call.
(Although I didn't do any serious performance testing, it appears that this
change does speed up running all the Junit tests by a few percent.)
Original issue reported on code.google.com by t.wolf...@gmail.com on 8 Jun 2011 at 11:42
Original issue reported on code.google.com by
t.wolf...@gmail.com
on 8 Jun 2011 at 11:42Attachments: