Skip to content

Commit

Permalink
Reuse inflater/deflater
Browse files Browse the repository at this point in the history
  • Loading branch information
marci4 committed Oct 8, 2024
1 parent a566891 commit 1e9fbbf
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ We can check the getRemaining() method to see whether the data we supplied has b
Note that this behavior doesn't occur if the message is "first compressed and then fragmented".
*/
if (inflater.getRemaining() > 0) {
inflater = new Inflater(true);
inflater.reset();
decompress(inputFrame.getPayloadData().array(), output);
}

if (inputFrame.isFin()) {
decompress(TAIL_BYTES, output);
// If context takeover is disabled, inflater can be reset.
if (clientNoContextTakeover) {
inflater = new Inflater(true);
inflater.reset();
}
}
} catch (DataFormatException e) {
Expand Down Expand Up @@ -244,8 +244,7 @@ public void encodeFrame(Framedata inputFrame) {
}

if (serverNoContextTakeover) {
deflater.end();
deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
deflater.reset();
}
}

Expand Down

0 comments on commit 1e9fbbf

Please sign in to comment.