From 99b0d6168bcb38cc9547bdb23b11482af353e600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Gaspard?= Date: Mon, 3 Oct 2022 16:43:37 +0200 Subject: [PATCH] collect signatures directly in the right collection This avoids creating a Vec to then recreate an Arc with the same information. In practice, this saves 10% of the time in an example taken from nearcore-private#4 --- lib/compiler/src/translator/sections.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/compiler/src/translator/sections.rs b/lib/compiler/src/translator/sections.rs index 9759c2d510..895d48503a 100644 --- a/lib/compiler/src/translator/sections.rs +++ b/lib/compiler/src/translator/sections.rs @@ -17,6 +17,7 @@ use crate::{WasmError, WasmResult}; use core::convert::TryFrom; use std::boxed::Box; use std::collections::HashMap; +use std::sync::Arc; use std::vec::Vec; use wasmer_types::entity::packed_option::ReservedValue; use wasmer_types::entity::EntityRef; @@ -60,14 +61,14 @@ pub fn parse_type_section( for entry in types { if let Ok(TypeDef::Func(WPFunctionType { params, returns })) = entry { - let sig_params: Vec = params + let sig_params: Arc<[Type]> = params .iter() .map(|ty| { wptype_to_type(*ty) .expect("only numeric types are supported in function signatures") }) .collect(); - let sig_returns: Vec = returns + let sig_returns: Arc<[Type]> = returns .iter() .map(|ty| { wptype_to_type(*ty)