From b191eef3e3e1b6bea510c7e64606d8442f974f8b Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 29 Oct 2021 14:42:54 +0200 Subject: [PATCH] core: replace vec.truncate(0) with vec.clear() --- nihav-core/src/compr/deflate.rs | 6 +++--- nihav-core/src/frame.rs | 2 +- nihav-core/src/reorder.rs | 2 +- nihav-core/src/scale/palette/elbg.rs | 6 +++--- nihav-core/src/scale/palette/mod.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nihav-core/src/compr/deflate.rs b/nihav-core/src/compr/deflate.rs index 2509fc2..7b36ead 100644 --- a/nihav-core/src/compr/deflate.rs +++ b/nihav-core/src/compr/deflate.rs @@ -1654,7 +1654,7 @@ impl LZParse for OptimalParser { } dst.reserve(src.len()); - self.trellis.truncate(0); + self.trellis.clear(); self.trellis.reserve(src.len() + 1); for _ in 0..=src.len() { self.trellis.push(TNode::default()); @@ -1897,7 +1897,7 @@ impl Deflate { Mode::Fixed => { wr.write(final_block as u16, 1); wr.write(1, 2); - self.tokens.truncate(0); + self.tokens.clear(); self.parser.parse(&self.srcbuf[..self.ssize], &mut self.tokens); let mut codes = CodeHuff::new(true); codes.make_codes(&self.tokens); @@ -1908,7 +1908,7 @@ impl Deflate { Mode::Dynamic => { wr.write(final_block as u16, 1); wr.write(2, 2); - self.tokens.truncate(0); + self.tokens.clear(); self.parser.parse(&self.srcbuf[..self.ssize], &mut self.tokens); let mut codes = CodeHuff::new(false); codes.make_codes(&self.tokens); diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 31cf8e8..f596dc9 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -752,7 +752,7 @@ impl NAVideoBufferPool { } /// Clears the pool from all frames. pub fn reset(&mut self) { - self.pool.truncate(0); + self.pool.clear(); } } diff --git a/nihav-core/src/reorder.rs b/nihav-core/src/reorder.rs index 6ae7e1a..ebd7bdf 100644 --- a/nihav-core/src/reorder.rs +++ b/nihav-core/src/reorder.rs @@ -159,7 +159,7 @@ impl FrameReorderer for ComplexReorderer { fn flush(&mut self) { self.last_ref_dts = None; self.ready_idx = 0; - self.frames.truncate(0); + self.frames.clear(); } fn get_last_frames(&mut self) -> Option { if !self.frames.is_empty() { diff --git a/nihav-core/src/scale/palette/elbg.rs b/nihav-core/src/scale/palette/elbg.rs index a9704f9..9a7d967 100644 --- a/nihav-core/src/scale/palette/elbg.rs +++ b/nihav-core/src/scale/palette/elbg.rs @@ -236,7 +236,7 @@ impl ELBG { self.clusters[i].reset(); } // put pixels into the nearest clusters - indices.truncate(0); + indices.clear(); for entry in entries.iter() { let mut bestidx = 0; let mut bestdist = std::u32::MAX; @@ -267,8 +267,8 @@ impl ELBG { } let dmean = dist / 256; - low_u.truncate(0); - high_u.truncate(0); + low_u.clear(); + high_u.clear(); let mut used = [false; 256]; for (i, cluster) in self.clusters.iter().enumerate() { if cluster.dist < dmean { diff --git a/nihav-core/src/scale/palette/mod.rs b/nihav-core/src/scale/palette/mod.rs index f9b0ee9..ce673ee 100644 --- a/nihav-core/src/scale/palette/mod.rs +++ b/nihav-core/src/scale/palette/mod.rs @@ -102,7 +102,7 @@ fn palettise_frame_internal(pic_in: &NABufferType, pic_out: &mut NABufferType, q let ofmt = dbuf.get_info().get_format(); let dst = dbuf.get_data_mut().unwrap(); - pixels.truncate(0); + pixels.clear(); if !ifmt.is_unpacked() { let esize = ifmt.elem_size as usize; let coffs = [ifmt.comp_info[0].unwrap().comp_offs as usize, ifmt.comp_info[1].unwrap().comp_offs as usize, ifmt.comp_info[2].unwrap().comp_offs as usize]; -- 2.39.5