From b597a6beef47299f7b1ffe6d9237fb0140589938 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Thu, 21 Jan 2021 09:43:26 -0800 Subject: [PATCH] Use Box<[Type]>` inside of `FunctionType` This saves 16 bytes (on 64bit systems) on the stack for each `FunctionType` and additional space on the heap by not allowing resizing (like Vec does) --- lib/wasmer-types/src/types.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/wasmer-types/src/types.rs b/lib/wasmer-types/src/types.rs index 37eb7846dab..6ed80e73ce5 100644 --- a/lib/wasmer-types/src/types.rs +++ b/lib/wasmer-types/src/types.rs @@ -229,9 +229,9 @@ impl ExternType { #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub struct FunctionType { /// The parameters of the function - params: Vec, + params: Box<[Type]>, /// The return values of the function - results: Vec, + results: Box<[Type]>, } impl FunctionType { @@ -242,8 +242,8 @@ impl FunctionType { Returns: Into>, { Self { - params: params.into(), - results: returns.into(), + params: params.into().into_boxed_slice(), + results: returns.into().into_boxed_slice(), } }