Skip to content

Commit

Permalink
Merge #2036
Browse files Browse the repository at this point in the history
2036: Use Box<[Type]>` inside of `FunctionType` r=syrusakbary a=MarkMcCaskey

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)

There are ways to save even more memory here but they're all heavier weight than this simple change.


Co-authored-by: Mark McCaskey <mark@wasmer.io>
  • Loading branch information
bors[bot] and Mark McCaskey authored Jan 21, 2021
2 parents e8344c5 + b597a6b commit b1405ce
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/wasmer-types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ impl ExternType {
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct FunctionType {
/// The parameters of the function
params: Vec<Type>,
params: Box<[Type]>,
/// The return values of the function
results: Vec<Type>,
results: Box<[Type]>,
}

impl FunctionType {
Expand All @@ -242,8 +242,8 @@ impl FunctionType {
Returns: Into<Vec<Type>>,
{
Self {
params: params.into(),
results: returns.into(),
params: params.into().into_boxed_slice(),
results: returns.into().into_boxed_slice(),
}
}

Expand Down

0 comments on commit b1405ce

Please sign in to comment.