fix some clippy warnings
[nihav.git] / nihav-realmedia / src / codecs / rv3040.rs
index e4d8420bb3b51c6922e764c329b440c8c4a79a78..bbaabdf87b738c12fe444b79067176e2b4269090 100644 (file)
@@ -91,18 +91,13 @@ impl MBType {
         }
     }
     pub fn is_fwd(self) -> bool {
-        match self {
+        matches!(self,
             MBType::MBP16x16 | MBType::MBP16x16Mix |
             MBType::MBP16x8 | MBType::MBP8x16 | MBType::MBP8x8 |
-            MBType::MBForward => true,
-            _ => false,
-        }
+            MBType::MBForward)
     }
     pub fn is_bwd(self) -> bool {
-        match self {
-            MBType::MBBidir | MBType::MBBackward => true,
-            _                  => false,
-        }
+        matches!(self, MBType::MBBidir | MBType::MBBackward)
     }
     pub fn has_mv_dir(self, fwd: bool) -> bool {
         match self {
@@ -113,10 +108,7 @@ impl MBType {
         }
     }
     pub fn is_nomv(self) -> bool {
-        match self {
-            MBType::MBIntra | MBType::MBIntra16 | MBType::MBSkip | MBType::MBDirect => true,
-            _                  => false,
-        }
+        matches!(self, MBType::MBIntra | MBType::MBIntra16 | MBType::MBSkip | MBType::MBDirect)
     }
     /*pub fn is_16x16(self) -> bool {
         match self {
@@ -326,13 +318,13 @@ impl MVInfo {
     }
     fn reset(&mut self) {
         let size = self.w * self.h;
-        self.mv_f.truncate(0);
+        self.mv_f.clear();
         self.mv_f.resize(size, ZERO_MV);
-        self.mv_b.truncate(0);
+        self.mv_b.clear();
         self.mv_b.resize(size, ZERO_MV);
-        self.has_f.truncate(0);
+        self.has_f.clear();
         self.has_f.resize(size >> 2, false);
-        self.has_b.truncate(0);
+        self.has_b.clear();
         self.has_b.resize(size >> 2, false);
     }
     fn fill(&mut self, mb_x: usize, mb_y: usize, fwd: bool, mv: MV) {
@@ -511,7 +503,7 @@ pub trait RV34DSP {
 fn parse_slice_offsets(src: &[u8], offsets: &mut Vec<usize>) -> DecoderResult<()> {
     let num_slices = (src[0] as usize) + 1;
     let ini_off = num_slices * 8 + 1;
-    offsets.truncate(0);
+    offsets.clear();
 
     if ini_off >= src.len() { return Err(DecoderError::ShortData); }
 
@@ -1057,7 +1049,7 @@ impl RV34Decoder {
         }
         Ok(())
     }
-    fn fill_deblock_flags(&self, sstate: &SState, mb_pos: usize, mbinfo: &mut Vec<RV34MBInfo>) {
+    fn fill_deblock_flags(&self, sstate: &SState, mb_pos: usize, mbinfo: &mut [RV34MBInfo]) {
         let mbt = mbinfo[mb_pos].mbtype;
         let mut hmvmask = 0;
         let mut vmvmask = 0;
@@ -1095,7 +1087,7 @@ impl RV34Decoder {
         }
     }
 
-    #[allow(clippy::cyclomatic_complexity)]
+    #[allow(clippy::cognitive_complexity)]
     pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut dyn RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> {
         let mut slice_offs: Vec<usize> = Vec::new();
         parse_slice_offsets(src, &mut slice_offs)?;