From 0c6e803318c33ddb64e22d946d2461f908f3435a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 11 Aug 2020 14:56:45 +0800 Subject: [PATCH] Allow resetting the Inflate state without zeroing the output buffer Related to #89 --- miniz_oxide/src/inflate/stream.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/miniz_oxide/src/inflate/stream.rs b/miniz_oxide/src/inflate/stream.rs index 39c602f3..db4a7647 100644 --- a/miniz_oxide/src/inflate/stream.rs +++ b/miniz_oxide/src/inflate/stream.rs @@ -98,8 +98,15 @@ impl InflateState { /// Reset the decompressor without re-allocating memory, using the given /// data format. pub fn reset(&mut self, data_format: DataFormat) { - self.decompressor().init(); + self.reset_without_zeroing_output_buffer(data_format); self.dict = [0; TINFL_LZ_DICT_SIZE]; + } + + /// Reset the decompressor without re-allocating memory, using the given + /// data format. It does not not zero the output buffer, which potentially + /// leaves decompressed bytes of previous runs in memory, but saves time. + pub fn reset_without_zeroing_output_buffer(&mut self, data_format: DataFormat) { + self.decompressor().init(); self.dict_ofs = 0; self.dict_avail = 0; self.first_call = true;