DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=36623>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=36623 ------- Additional Comments From [EMAIL PROTECTED] 2005-09-12 22:11 ------- This readByte() implementation will probably be slower than BufferedIndexInput's. In particular, the call to buffers.elementAt() is not cheap. It would be faster to cache the current buffer in a field. Fastest would be to also cache the position in the buffer, something like the following (untested): private static final EMPTY_BUFFER = new byte[0]; private byte[] buffer = EMPTY_BUFFER; private int bufferPosition; public byte readByte() { if (bufferPosition == buffer.length) { pointer += buffer.length; updateBuffer(); } return buffer[bufferPosition++]; } public byte readBytes(byte[] dest, int destOffset, int len) { int start = pointer + bufferPosition; ... your code ... updateBuffer(); } public void seek(long pos) { pointer = (int)pos; updateBuffer(); } public long getFilePointer() { return pointer + bufferPosition; } private void updateBuffer() { if (pointer < length) { buffer = file.buffers.elementAt(pointer/BUFFER_SIZE)); bufferPosition = pointer%BUFFER_SIZE; } else { buffer = EMPTY_BUFFER; bufferPosition = 0; } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]