Skip to content

Commit aa9329b

Browse files
bors[bot]Mark McCaskey
and
Mark McCaskey
authoredJan 21, 2021
Merge #2036
2036: Use Box<[Type]>` inside of `FunctionType` r=MarkMcCaskey 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>
2 parents e8344c5 + b597a6b commit aa9329b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎lib/wasmer-types/src/types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ impl ExternType {
229229
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
230230
pub struct FunctionType {
231231
/// The parameters of the function
232-
params: Vec<Type>,
232+
params: Box<[Type]>,
233233
/// The return values of the function
234-
results: Vec<Type>,
234+
results: Box<[Type]>,
235235
}
236236

237237
impl FunctionType {
@@ -242,8 +242,8 @@ impl FunctionType {
242242
Returns: Into<Vec<Type>>,
243243
{
244244
Self {
245-
params: params.into(),
246-
results: returns.into(),
245+
params: params.into().into_boxed_slice(),
246+
results: returns.into().into_boxed_slice(),
247247
}
248248
}
249249

0 commit comments

Comments
 (0)