diff --git a/beacon_chain/utils/ssz/src/decode.rs b/beacon_chain/utils/ssz/src/decode.rs index 3d81b70ba..53f82547c 100644 --- a/beacon_chain/utils/ssz/src/decode.rs +++ b/beacon_chain/utils/ssz/src/decode.rs @@ -1,5 +1,3 @@ -#![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))] - use super::{ LENGTH_BYTES, }; @@ -79,10 +77,10 @@ pub fn decode_length(bytes: &[u8], index: usize, length_bytes: usize) return Err(DecodeError::TooShort); }; let mut len: usize = 0; - for i in index..index+length_bytes { + for (i, byte) in bytes.iter().enumerate().take(index+length_bytes).skip(index) { let offset = (index+length_bytes - i - 1) * 8; - len |= (bytes[i] as usize) << offset; - }; + len |= (*byte as usize) << offset; + } Ok(len) }