fix some clippy warnings
[nihav.git] / nihav-core / src / compr / deflate.rs
index 7b36eadff327dcb3d300d058c79633a527040c98..71e0dfed331d8292ac9675d74e06a1c77c8a67ef 100644 (file)
@@ -356,12 +356,17 @@ impl Inflate {
         self.full_pos += len;
         Ok(())
     }
+    ///! Sets custom history for decoding an update for already decoded data.
+    pub fn set_dict(&mut self, dict: &[u8]) {
+        let len = dict.len().min(self.buf.len());
+        let start = dict.len() - len;
+        self.buf[..len].copy_from_slice(&dict[start..]);
+        self.bpos = len;
+        self.full_pos = len;
+    }
     ///! Reports whether decoder has finished decoding the input.
     pub fn is_finished(&self) -> bool {
-        match self.state {
-            InflateState::End => true,
-            _ => false,
-        }
+        matches!(self.state, InflateState::End)
     }
     ///! Reports the current amount of bytes output into the destination buffer after the last run.
     pub fn get_current_output_size(&self) -> usize { self.output_idx }
@@ -616,7 +621,7 @@ impl Inflate {
                         let (lit_lengths, dist_lengths) = self.all_lengths.split_at(self.hlit);
 
                         let mut lit_codes = [ShortCodebookDesc { code: 0, bits: 0 }; NUM_LITERALS];
-                        lengths_to_codes(&lit_lengths, &mut lit_codes)?;
+                        lengths_to_codes(lit_lengths, &mut lit_codes)?;
                         let mut cr = ShortCodebookDescReader::new(lit_codes.to_vec());
                         let ret = Codebook::new(&mut cr, CodebookMode::LSB);
                         if ret.is_err() { return Err(DecompressError::InvalidHeader); }