Skip to content

Commit

Permalink
uint_min(size, 16); > core::cmp::min
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Aug 6, 2024
1 parent faab8f0 commit 307e3d6
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions packages/bytes/src/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn keccak_u128s_be(input: Span<u128>, n_bytes: usize) -> u256 {
let mut keccak_input = array![];
let mut size = n_bytes;
for v in input {
let value_size = uint_min(size, 16);
let value_size = core::cmp::min(size, 16);
keccak_add_uint128_be(ref keccak_input, *v, value_size);
size -= value_size;
};
Expand All @@ -74,16 +74,6 @@ pub fn keccak_u128s_be(input: Span<u128>, n_bytes: usize) -> u256 {
}
}

/// return the minimal value
/// support u8, u16, u32, u64, u128, u256
fn uint_min<T, +Drop<T>, +PartialOrd<T>, +Copy<T>>(l: T, r: T) -> T {
if l <= r {
l
} else {
r
}
}

fn u256_reverse_endian(input: u256) -> u256 {
let low = u128_byte_reverse(input.high);
let high = u128_byte_reverse(input.low);
Expand Down

0 comments on commit 307e3d6

Please sign in to comment.