redundant if and type conversion change
This commit is contained in:
parent
2fb9dfbf14
commit
ba65bdfc6a
@ -20,7 +20,7 @@ macro_rules! impl_decodable_for_uint {
|
|||||||
let mut result: $type = 0;
|
let mut result: $type = 0;
|
||||||
for i in index..end_bytes {
|
for i in index..end_bytes {
|
||||||
let offset = ((index + max_bytes) - i - 1) * 8;
|
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))
|
Ok((result, end_bytes))
|
||||||
} else {
|
} else {
|
||||||
@ -52,10 +52,7 @@ impl Decodable for H256 {
|
|||||||
fn ssz_decode(bytes: &[u8], index: usize)
|
fn ssz_decode(bytes: &[u8], index: usize)
|
||||||
-> Result<(Self, usize), DecodeError>
|
-> Result<(Self, usize), DecodeError>
|
||||||
{
|
{
|
||||||
if bytes.len() < 32 {
|
if bytes.len() < 32 || bytes.len() - 32 < index {
|
||||||
return Err(DecodeError::TooShort)
|
|
||||||
}
|
|
||||||
else if bytes.len() - 32 < index {
|
|
||||||
return Err(DecodeError::TooShort)
|
return Err(DecodeError::TooShort)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user