> Please review this modification of `java.io.InputStream.skipNBytes(long)` to > improve its performance when `skip(long)` skips fewer than the requested > number of bytes. In the current implementation, `skip(long)` is invoked once > and, if not enough bytes have been skipped, then `read()` is invoked for each > of the remaining bytes to be skipped. The proposed implementation instead > repeatedly invokes `skip(long)` until the requested number of bytes has been > skipped, or an error condition is encountered. For cases where `skip(long)` > skips fewer bytes than the number requested, the new version was measured to > be up to more than one thousand times faster than the old version. When > `skip(long)` actually skips the requested number of bytes, the performance > difference is insignificant.
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 ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/1329/files - new: https://git.openjdk.java.net/jdk/pull/1329/files/331f3fcc..f59d7a35 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=1329&range=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=1329&range=00-01 Stats: 8 lines in 1 file changed: 1 ins; 0 del; 7 mod Patch: https://git.openjdk.java.net/jdk/pull/1329.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/1329/head:pull/1329 PR: https://git.openjdk.java.net/jdk/pull/1329