diff options
author | Devon Sawatsky <novedevo@gmail.com> | 2023-10-21 22:37:37 -0700 |
---|---|---|
committer | Devon Sawatsky <novedevo@gmail.com> | 2023-10-21 22:37:37 -0700 |
commit | 703c10b9a1803a3416c24be3ecf415193cc361e7 (patch) | |
tree | bf7b8a19dd894472c8814a7e81fd13f41b710104 | |
parent | 8eb97b076f4fb22e7420708d32e11cf03fa4f2e6 (diff) | |
download | gifed-703c10b9a1803a3416c24be3ecf415193cc361e7.tar.gz gifed-703c10b9a1803a3416c24be3ecf415193cc361e7.zip |
replace using pow to compute 2^n with left shift
-rw-r--r-- | gifed/src/block/palette.rs | 2 | ||||
-rw-r--r-- | 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 |