mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
wasm: Use Ord::max where possible instead of a custom function
This commit is contained in:
parent
a55461d0f8
commit
a6faf875f8
2 changed files with 3 additions and 14 deletions
|
@ -205,19 +205,12 @@ impl<T: Wasm32Sized, E: Wasm32Sized> Wasm32Result for RocResult<T, E> {
|
|||
build_wrapper_body_stack_memory(
|
||||
code_builder,
|
||||
main_function_index,
|
||||
max2(T::ACTUAL_WIDTH, E::ACTUAL_WIDTH) + max2(T::ALIGN_OF_WASM, E::ALIGN_OF_WASM),
|
||||
Ord::max(T::ACTUAL_WIDTH, E::ACTUAL_WIDTH)
|
||||
+ Ord::max(T::ALIGN_OF_WASM, E::ALIGN_OF_WASM),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn max2(a: usize, b: usize) -> usize {
|
||||
if a > b {
|
||||
a
|
||||
} else {
|
||||
b
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Wasm32Result> Wasm32Result for &'_ T {
|
||||
build_wrapper_body_primitive!(i32_store, Align::Bytes4);
|
||||
}
|
||||
|
|
|
@ -99,11 +99,7 @@ impl<T: FromWasmerMemory + Wasm32Sized, E: FromWasmerMemory + Wasm32Sized> FromW
|
|||
for RocResult<T, E>
|
||||
{
|
||||
fn decode(memory: &wasmer::Memory, offset: u32) -> Self {
|
||||
let tag_offset = if T::ACTUAL_WIDTH > E::ACTUAL_WIDTH {
|
||||
T::ACTUAL_WIDTH
|
||||
} else {
|
||||
E::ACTUAL_WIDTH
|
||||
};
|
||||
let tag_offset = Ord::max(T::ACTUAL_WIDTH, E::ACTUAL_WIDTH);
|
||||
let tag = <u8 as FromWasmerMemory>::decode(memory, offset + tag_offset as u32);
|
||||
if tag == 1 {
|
||||
let value = <T as FromWasmerMemory>::decode(memory, offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue