diff options
author | Eugene Kliuchnikov <eustas@google.com> | 2017-04-05 18:50:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 18:50:01 +0200 |
commit | 21c118ba776a1e93a30397bdd66636a6f3c0b06b (patch) | |
tree | 8eb99646dd4a1b5cca9cc02eb1c5fe33dce10514 /java/org/brotli/dec/BrotliInputStream.java | |
parent | e12a7a2d2859809c25b1941cf48ef17d55514efd (diff) | |
download | brotli-21c118ba776a1e93a30397bdd66636a6f3c0b06b.zip brotli-21c118ba776a1e93a30397bdd66636a6f3c0b06b.tar.gz brotli-21c118ba776a1e93a30397bdd66636a6f3c0b06b.tar.bz2 |
Update c- and java-decoder: (#536)
* speedup java decoder
* avoid masking
* avoid excessive fillBits
* streamline uncompressed block processing
* make java decoder more transpilation-friendly
* avoid non-essential goto in c-decoder
Diffstat (limited to 'java/org/brotli/dec/BrotliInputStream.java')
-rwxr-xr-x | java/org/brotli/dec/BrotliInputStream.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/java/org/brotli/dec/BrotliInputStream.java b/java/org/brotli/dec/BrotliInputStream.java index 9117d9b..a6ce5e9 100755 --- a/java/org/brotli/dec/BrotliInputStream.java +++ b/java/org/brotli/dec/BrotliInputStream.java @@ -97,7 +97,7 @@ public class BrotliInputStream extends InputStream { try { State.setInput(state, source); } catch (BrotliRuntimeException ex) { - throw new IOException(ex); + throw new IOException("Brotli decoder initialization failed", ex); } if (customDictionary != null) { Decode.setCustomDictionary(state, customDictionary); @@ -117,18 +117,14 @@ public class BrotliInputStream extends InputStream { */ @Override public int read() throws IOException { - try { - if (bufferOffset >= remainingBufferBytes) { - remainingBufferBytes = read(buffer, 0, buffer.length); - bufferOffset = 0; - if (remainingBufferBytes == -1) { - return -1; - } + if (bufferOffset >= remainingBufferBytes) { + remainingBufferBytes = read(buffer, 0, buffer.length); + bufferOffset = 0; + if (remainingBufferBytes == -1) { + return -1; } - return buffer[bufferOffset++] & 0xFF; - } catch (BrotliRuntimeException ex) { - throw new IOException(ex); } + return buffer[bufferOffset++] & 0xFF; } /** @@ -168,7 +164,7 @@ public class BrotliInputStream extends InputStream { } return state.outputUsed + copyLen; } catch (BrotliRuntimeException ex) { - throw new IOException(ex); + throw new IOException("Brotli stream decoding failed", ex); } } } |