From a8a6e4e69d4d76063a71da752d410dfac65510dd Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Tue, 29 Sep 2020 12:49:46 +0800 Subject: [PATCH] optimize get_wasmtime_signature (#2243) --- crates/wasmtime/src/types.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/wasmtime/src/types.rs b/crates/wasmtime/src/types.rs index 35c03acb35..d8a3ad27b6 100644 --- a/crates/wasmtime/src/types.rs +++ b/crates/wasmtime/src/types.rs @@ -252,21 +252,20 @@ impl FuncType { use wasmtime_environ::ir::{AbiParam, ArgumentPurpose, Signature}; use wasmtime_jit::native; let call_conv = native::call_conv(); - let mut params = self - .params - .iter() - .map(|p| AbiParam::new(p.get_wasmtime_type())) - .collect::>(); + let mut params = vec![ + AbiParam::special(pointer_type, ArgumentPurpose::VMContext), + AbiParam::new(pointer_type), + ]; + params.extend( + self.params + .iter() + .map(|p| AbiParam::new(p.get_wasmtime_type())), + ); let returns = self .results .iter() .map(|p| AbiParam::new(p.get_wasmtime_type())) .collect::>(); - params.insert( - 0, - AbiParam::special(pointer_type, ArgumentPurpose::VMContext), - ); - params.insert(1, AbiParam::new(pointer_type)); Signature { params,