Skip to content

Commit 5bdb78b

Browse files
authored
perf(wave): avoid Vec allocation in make_tuple (#12464)
1 parent 4c2e3d2 commit 5bdb78b

File tree

1 file changed

+10
-5
lines changed
  • crates/wasmtime/src/runtime/wave

1 file changed

+10
-5
lines changed

crates/wasmtime/src/runtime/wave/core.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ impl WasmValue for crate::Val {
7070
));
7171
}
7272
}
73-
let [l_val, h_val]: [Self; 2] = vals
74-
.into_iter()
75-
.collect::<Vec<_>>()
76-
.try_into()
77-
.map_err(|_| WasmValueError::Other("expected 2 values".to_string()))?;
73+
let mut iter = vals.into_iter();
74+
let Some(l_val) = iter.next() else {
75+
return Err(WasmValueError::Other("expected 2 values".to_string()));
76+
};
77+
let Some(h_val) = iter.next() else {
78+
return Err(WasmValueError::Other("expected 2 values".to_string()));
79+
};
80+
if iter.next().is_some() {
81+
return Err(WasmValueError::Other("expected 2 values".to_string()));
82+
}
7883

7984
let (Some(l), Some(h)) = (l_val.i64(), h_val.i64()) else {
8085
return Err(WasmValueError::Other("expected 2 i64s (v64x2)".to_string()));

0 commit comments

Comments
 (0)