Remove some calls to clone() by using into_iter().

This commit is contained in:
Nick Lewycky
2020-05-15 17:24:56 -07:00
parent fce8e32cf6
commit aa4aa65d0c
2 changed files with 5 additions and 8 deletions

View File

@ -101,11 +101,11 @@ impl Compiler for LLVMCompiler {
)
})
.collect::<Result<Vec<_>, CompileError>>()?
.iter()
.map(|(compiled_function, function_custom_sections)| {
// TODO: remove usage of clone
.into_iter()
.map(|(mut compiled_function, mut function_custom_sections)| {
let first_section = module_custom_sections.len() as u32;
for (_, custom_section) in function_custom_sections.iter() {
// TODO: remove this call to clone()
let mut custom_section = custom_section.clone();
for mut reloc in &mut custom_section.relocations {
match reloc.reloc_target {
@ -119,7 +119,6 @@ impl Compiler for LLVMCompiler {
}
module_custom_sections.push(custom_section);
}
let mut compiled_function = compiled_function.clone();
for mut reloc in &mut compiled_function.relocations {
match reloc.reloc_target {
RelocationTarget::CustomSection(index) => {
@ -132,7 +131,6 @@ impl Compiler for LLVMCompiler {
}
compiled_function
})
.into_iter()
.collect::<PrimaryMap<LocalFunctionIndex, _>>();
Ok(Compilation::new(functions, module_custom_sections))