diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-06-26 18:44:17 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-06-26 18:44:17 +0200 |
commit | 25fd05c73b167f37e58ec5601846f9b77e2d03a4 (patch) | |
tree | 145957cbd348085e377962f3d4d3fded0acfeaf2 | |
parent | 6bb2692727d9617c7f349c037761f8e83198f840 (diff) | |
download | nihav-25fd05c73b167f37e58ec5601846f9b77e2d03a4.tar.gz |
msvideo1enc: get rid of small repeated allocation
-rw-r--r-- | nihav-ms/src/codecs/msvideo1enc.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs index cdad0ce..8a6281d 100644 --- a/nihav-ms/src/codecs/msvideo1enc.rs +++ b/nihav-ms/src/codecs/msvideo1enc.rs @@ -50,7 +50,8 @@ impl VQElement for Pixel16 { for i in 0..31 { offs[i + 1] = offs[i] + counts[i]; } - let mut dst = vec![Pixel16(0); arr.len()]; + let mut dst = [Pixel16(0); 16]; + assert!(dst.len() >= arr.len()); for pix in arr.iter() { let (r, g, b) = pix.unpack(); let idx = match component { @@ -61,7 +62,8 @@ impl VQElement for Pixel16 { dst[offs[idx]] = *pix; offs[idx] += 1; } - arr.copy_from_slice(dst.as_slice()); + let len = arr.len(); + arr.copy_from_slice(&dst[..len]); } fn max_dist_component(min: &Self, max: &Self) -> usize { let (r0, g0, b0) = max.unpack(); |