replace vec.truncate(0) with vec.clear()
[nihav.git] / nihav-codec-support / src / data / mod.rs
index 35a89736b72075a71e6d4305b9bc667e6795f401..eba029939a3a46643dea1fd3a650a7eccf1f3927 100644 (file)
@@ -5,7 +5,7 @@
 /// In the decoding process of many codecs there is a need to store some previously decoded information and only immediate top neighbours are used.
 /// This can be done by storing either the full information for the whole frame or just the top line and move information for last decoded row to the top every time when row decoding is done.
 /// `GenericCache` implements the second approach.
-/// 
+///
 /// # Examples
 ///
 /// Create a cache for one line and use top pixel for prediction:
@@ -44,17 +44,17 @@ impl<T:Copy> GenericCache<T> {
                 stride,
                 height,
                 xpos:   0,
-                data:   Vec::with_capacity((height + 1) * stride),
+                data:   Vec::with_capacity((height + 1) * stride + 1),
                 default,
             };
         ret.reset();
         ret
     }
     /// Reports the total amount of elements stored.
-    pub fn full_size(&self) -> usize { self.stride * (self.height + 1) }
+    pub fn full_size(&self) -> usize { self.stride * (self.height + 1) + 1 }
     /// Resets the cache state.
     pub fn reset(&mut self) {
-        self.data.truncate(0);
+        self.data.clear();
         let size = self.full_size();
         self.data.resize(size, self.default);
         self.xpos = self.stride + 1;