From 703c10b9a1803a3416c24be3ecf415193cc361e7 Mon Sep 17 00:00:00 2001 From: Devon Sawatsky Date: Sat, 21 Oct 2023 22:37:37 -0700 Subject: replace using pow to compute 2^n with left shift --- gifed/src/block/palette.rs | 2 +- gifed/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gifed/src/block/palette.rs b/gifed/src/block/palette.rs index 534cfeb..9c4a5a9 100644 --- a/gifed/src/block/palette.rs +++ b/gifed/src/block/palette.rs @@ -42,7 +42,7 @@ impl Palette { /// Returns the number of items that the decoder *thinks* is in the palette. /// This is 2^(n + 1) where n = [Palette::packed_len] pub fn computed_len(&self) -> usize { - 2usize.pow(self.packed_len() as u32 + 1) + 1 << (self.packed_len() + 1) } /// Pushes a color on to the end of the table diff --git a/gifed/src/lib.rs b/gifed/src/lib.rs index 966b46c..cfb124f 100644 --- a/gifed/src/lib.rs +++ b/gifed/src/lib.rs @@ -16,7 +16,7 @@ pub use lzw::LZW; /// Perform the algorithm to get the length of a color table from /// the value of the packed field. The max value here is 256 pub(crate) fn packed_to_color_table_length(packed: u8) -> usize { - 2usize.pow(packed as u32 + 1) + 1 << (packed + 1) } //TODO: Be sure to check that fields in LSD and Img. Desc. that were reserved -- cgit 1.4.1-3-g733a5