jpountz commented on a change in pull request #1338: LUCENE-9271: Move BufferedIndexInput to the ByteBuffer API URL: https://github.com/apache/lucene-solr/pull/1338#discussion_r390828520
########## File path: lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java ########## @@ -154,65 +144,60 @@ public final void readBytes(byte[] b, int offset, int len, boolean useBuffer) th // this function, there is no need to do a seek // here, because there's no need to reread what we // had in the buffer. - long after = bufferStart+bufferPosition+len; + long after = bufferStart+buffer.position()+len; if(after > length()) throw new EOFException("read past EOF: " + this); - readInternal(b, offset, len); + readInternal(ByteBuffer.wrap(b, offset, len)); bufferStart = after; - bufferPosition = 0; - bufferLength = 0; // trigger refill() on read + buffer.position(0); + buffer.limit(0); // trigger refill() on read } } } @Override public final short readShort() throws IOException { - if (2 <= (bufferLength-bufferPosition)) { - return (short) (((buffer[bufferPosition++] & 0xFF) << 8) | (buffer[bufferPosition++] & 0xFF)); + if (Short.BYTES <= buffer.remaining()) { + return buffer.getShort(); Review comment: Yes: "Specific byte orders are represented by instances of the ByteOrder class. The initial order of a byte buffer is always BIG_ENDIAN." (https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/ByteBuffer.html) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org