Use with_capacity to minimize reallocation.
This commit is contained in:
@@ -87,8 +87,8 @@ pub fn compile_module<'data, 'module>(
|
|||||||
function_body_inputs: PrimaryMap<DefinedFuncIndex, &'data [u8]>,
|
function_body_inputs: PrimaryMap<DefinedFuncIndex, &'data [u8]>,
|
||||||
isa: &dyn isa::TargetIsa,
|
isa: &dyn isa::TargetIsa,
|
||||||
) -> Result<(Compilation, Relocations), CompileError> {
|
) -> Result<(Compilation, Relocations), CompileError> {
|
||||||
let mut functions = PrimaryMap::new();
|
let mut functions = PrimaryMap::with_capacity(function_body_inputs.len());
|
||||||
let mut relocations = PrimaryMap::new();
|
let mut relocations = PrimaryMap::with_capacity(function_body_inputs.len());
|
||||||
for (i, input) in function_body_inputs.into_iter() {
|
for (i, input) in function_body_inputs.into_iter() {
|
||||||
let func_index = module.func_index(i);
|
let func_index = module.func_index(i);
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user