On Fri, 20 Nov 2020 09:56:16 GMT, sergus13 <github.com+74766043+sergu...@openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with two >> additional commits since the last revision: >> >> - 8246739: InputStream.skipNBytes could be implemented more efficiently >> - 8246739: InputStream.skipNBytes could be implemented more efficiently > > src/java.base/share/classes/java/io/InputStream.java line 607: > >> 605: if (read() < 0) { >> 606: throw new EOFException(); >> 607: } > > Shouldn't we decrement "n" in case "read" returns non-negative value? > > if (read() < 0) { > throw new EOFException(); > } else { > n--; > } > ` One more notice here. Wouldn't it be better to compare value returned by read method with -1 (as it was before)? Since documentation of read method says: _Returns: the next byte of data, or -1 if the end of the stream is reached._ ` if (read() != -1) { throw new EOFException(); } else { n--; } ` ------------- PR: https://git.openjdk.java.net/jdk/pull/1329