From ba65bdfc6a78b0046574e4d27004c60e1b7a6eb7 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sat, 20 Oct 2018 14:20:23 -0500 Subject: [PATCH] redundant if and type conversion change --- beacon_chain/utils/ssz/src/impl_decode.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/beacon_chain/utils/ssz/src/impl_decode.rs b/beacon_chain/utils/ssz/src/impl_decode.rs index 2833037f3..b86af1365 100644 --- a/beacon_chain/utils/ssz/src/impl_decode.rs +++ b/beacon_chain/utils/ssz/src/impl_decode.rs @@ -20,7 +20,7 @@ macro_rules! impl_decodable_for_uint { let mut result: $type = 0; for i in index..end_bytes { let offset = ((index + max_bytes) - i - 1) * 8; - result = ((bytes[i] as $type) << offset) | result; + result |= ($type::from(bytes[i])) << offset; }; Ok((result, end_bytes)) } else { @@ -52,10 +52,7 @@ impl Decodable for H256 { fn ssz_decode(bytes: &[u8], index: usize) -> Result<(Self, usize), DecodeError> { - if bytes.len() < 32 { - return Err(DecodeError::TooShort) - } - else if bytes.len() - 32 < index { + if bytes.len() < 32 || bytes.len() - 32 < index { return Err(DecodeError::TooShort) } else {