Skip to content

Commit

Permalink
Use with_capacity to minimize reallocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Mar 1, 2019
1 parent cd21efd commit 538ef20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/environ/src/cranelift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ pub fn compile_module<'data, 'module>(
function_body_inputs: PrimaryMap<DefinedFuncIndex, &'data [u8]>,
isa: &dyn isa::TargetIsa,
) -> Result<(Compilation, Relocations), CompileError> {
let mut functions = PrimaryMap::new();
let mut relocations = PrimaryMap::new();
let mut functions = PrimaryMap::with_capacity(function_body_inputs.len());
let mut relocations = PrimaryMap::with_capacity(function_body_inputs.len());
for (i, input) in function_body_inputs.into_iter() {
let func_index = module.func_index(i);
let mut context = Context::new();
Expand Down

0 comments on commit 538ef20

Please sign in to comment.