Pass declare_signature's argument by value.

`parse_type_section` doesn't need the value after passing it, and this
allows callees to avoid cloning if they need their own copy.
This commit is contained in:
Dan Gohman
2019-01-07 12:34:21 -08:00
parent 13138b65f7
commit a7aee246e9
3 changed files with 4 additions and 4 deletions

View File

@@ -350,8 +350,8 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
self.info.config self.info.config
} }
fn declare_signature(&mut self, sig: &ir::Signature) { fn declare_signature(&mut self, sig: ir::Signature) {
self.info.signatures.push(sig.clone()); self.info.signatures.push(sig);
} }
fn declare_func_import( fn declare_func_import(

View File

@@ -250,7 +250,7 @@ pub trait ModuleEnvironment<'data> {
fn reserve_signatures(&mut self, _num: u32) {} fn reserve_signatures(&mut self, _num: u32) {}
/// Declares a function signature to the environment. /// Declares a function signature to the environment.
fn declare_signature(&mut self, sig: &ir::Signature); fn declare_signature(&mut self, sig: ir::Signature);
/// Provides the number of imports up front. By default this does nothing, but /// Provides the number of imports up front. By default this does nothing, but
/// implementations can use this to preallocate memory if desired. /// implementations can use this to preallocate memory if desired.

View File

@@ -48,7 +48,7 @@ pub fn parse_type_section(
.expect("only numeric types are supported in function signatures"); .expect("only numeric types are supported in function signatures");
AbiParam::new(cret_arg) AbiParam::new(cret_arg)
})); }));
environ.declare_signature(&sig); environ.declare_signature(sig);
} }
ref s => panic!("unsupported type: {:?}", s), ref s => panic!("unsupported type: {:?}", s),
} }