Skip to content

Commit

Permalink
Remove more obviated clone() calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Apr 20, 2020
1 parent ad9414d commit b2b5e8d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion crates/api/src/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl Table {

/// Returns the current size of this table.
pub fn size(&self) -> u32 {
unsafe { (&*self.wasmtime_export.definition).current_elements }
unsafe { (*self.wasmtime_export.definition).current_elements }
}

/// Grows the size of this table by `delta` more elements, initialization
Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Linker {
let items = self
.iter()
.filter(|(m, _, _)| *m == module)
.map(|(_, name, item)| (name.to_string(), item.clone()))
.map(|(_, name, item)| (name.to_string(), item))
.collect::<Vec<_>>();
for (name, item) in items {
self.define(as_module, &name, item)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/api/src/trampoline/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn create_handle_with_function(

let pointer_type = isa.pointer_type();
let sig = match ft.get_wasmtime_signature(pointer_type) {
Some(sig) => sig.clone(),
Some(sig) => sig,
None => bail!("not a supported core wasm signature {:?}", ft),
};

Expand Down Expand Up @@ -276,7 +276,7 @@ pub unsafe fn create_handle_with_raw_function(

let pointer_type = isa.pointer_type();
let sig = match ft.get_wasmtime_signature(pointer_type) {
Some(sig) => sig.clone(),
Some(sig) => sig,
None => bail!("not a supported core wasm signature {:?}", ft),
};

Expand Down
8 changes: 4 additions & 4 deletions crates/c-api/src/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ pub extern "C" fn wasm_extern_kind(e: &wasm_extern_t) -> wasm_externkind_t {
#[no_mangle]
pub extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externtype_t> {
let ty = match &e.which {
ExternHost::Func(f) => ExternType::Func(f.borrow().ty().clone()),
ExternHost::Global(f) => ExternType::Global(f.borrow().ty().clone()),
ExternHost::Table(f) => ExternType::Table(f.borrow().ty().clone()),
ExternHost::Memory(f) => ExternType::Memory(f.borrow().ty().clone()),
ExternHost::Func(f) => ExternType::Func(f.borrow().ty()),
ExternHost::Global(f) => ExternType::Global(f.borrow().ty()),
ExternHost::Table(f) => ExternType::Table(f.borrow().ty()),
ExternHost::Memory(f) => ExternType::Memory(f.borrow().ty()),
};
Box::new(wasm_externtype_t::new(ty))
}
Expand Down
10 changes: 5 additions & 5 deletions crates/c-api/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn _wasmtime_func_call(

#[no_mangle]
pub extern "C" fn wasm_func_type(f: &wasm_func_t) -> Box<wasm_functype_t> {
Box::new(wasm_functype_t::new(f.func().borrow().ty().clone()))
Box::new(wasm_functype_t::new(f.func().borrow().ty()))
}

#[no_mangle]
Expand All @@ -272,10 +272,10 @@ pub unsafe extern "C" fn wasmtime_caller_export_get(
let name = str::from_utf8(name.as_slice()).ok()?;
let export = caller.caller.get_export(name)?;
let which = match export {
Extern::Func(f) => ExternHost::Func(HostRef::new(f.clone())),
Extern::Global(g) => ExternHost::Global(HostRef::new(g.clone())),
Extern::Memory(m) => ExternHost::Memory(HostRef::new(m.clone())),
Extern::Table(t) => ExternHost::Table(HostRef::new(t.clone())),
Extern::Func(f) => ExternHost::Func(HostRef::new(f)),
Extern::Global(g) => ExternHost::Global(HostRef::new(g)),
Extern::Memory(m) => ExternHost::Memory(HostRef::new(m)),
Extern::Table(t) => ExternHost::Table(HostRef::new(t)),
};
Some(Box::new(wasm_extern_t { which }))
}
2 changes: 1 addition & 1 deletion crates/c-api/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub extern "C" fn wasm_global_as_extern(g: &wasm_global_t) -> &wasm_extern_t {

#[no_mangle]
pub extern "C" fn wasm_global_type(g: &wasm_global_t) -> Box<wasm_globaltype_t> {
let globaltype = g.global().borrow().ty().clone();
let globaltype = g.global().borrow().ty();
Box::new(wasm_globaltype_t::new(globaltype))
}

Expand Down
8 changes: 4 additions & 4 deletions crates/c-api/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ pub extern "C" fn wasm_instance_exports(instance: &wasm_instance_t, out: &mut wa
instance
.exports()
.map(|e| match e.external {
Extern::Func(f) => ExternHost::Func(HostRef::new(f.clone())),
Extern::Global(f) => ExternHost::Global(HostRef::new(f.clone())),
Extern::Memory(f) => ExternHost::Memory(HostRef::new(f.clone())),
Extern::Table(f) => ExternHost::Table(HostRef::new(f.clone())),
Extern::Func(f) => ExternHost::Func(HostRef::new(f)),
Extern::Global(f) => ExternHost::Global(HostRef::new(f)),
Extern::Memory(f) => ExternHost::Memory(HostRef::new(f)),
Extern::Table(f) => ExternHost::Table(HostRef::new(f)),
})
.collect()
});
Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub extern "C" fn wasm_memory_as_extern(m: &wasm_memory_t) -> &wasm_extern_t {

#[no_mangle]
pub extern "C" fn wasm_memory_type(m: &wasm_memory_t) -> Box<wasm_memorytype_t> {
let ty = m.memory().borrow().ty().clone();
let ty = m.memory().borrow().ty();
Box::new(wasm_memorytype_t::new(ty))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub unsafe extern "C" fn wasm_table_new(

#[no_mangle]
pub extern "C" fn wasm_table_type(t: &wasm_table_t) -> Box<wasm_tabletype_t> {
let ty = t.table().borrow().ty().clone();
let ty = t.table().borrow().ty();
Box::new(wasm_tabletype_t::new(ty))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/src/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub unsafe extern "C" fn wasi_instance_new(
})),
Err(e) => {
*trap = Box::into_raw(Box::new(wasm_trap_t {
trap: HostRef::new(Trap::new(e.to_string())),
trap: HostRef::new(Trap::new(e)),
}));

None
Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/src/wat2wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pub extern "C" fn wasmtime_wat2wasm(
Err(_) => return bad_utf8(),
};
handle_result(wat::parse_str(wat).map_err(|e| e.into()), |bytes| {
ret.set_buffer(bytes.into())
ret.set_buffer(bytes)
})
}

0 comments on commit b2b5e8d

Please sign in to comment.