Skip to content

Commit b2b5e8d

Browse files
committed
Remove more obviated clone() calls.
1 parent ad9414d commit b2b5e8d

File tree

11 files changed

+22
-22
lines changed

11 files changed

+22
-22
lines changed

crates/api/src/externals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl Table {
374374

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

380380
/// Grows the size of this table by `delta` more elements, initialization

crates/api/src/linker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl Linker {
283283
let items = self
284284
.iter()
285285
.filter(|(m, _, _)| *m == module)
286-
.map(|(_, name, item)| (name.to_string(), item.clone()))
286+
.map(|(_, name, item)| (name.to_string(), item))
287287
.collect::<Vec<_>>();
288288
for (name, item) in items {
289289
self.define(as_module, &name, item)?;

crates/api/src/trampoline/func.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub fn create_handle_with_function(
212212

213213
let pointer_type = isa.pointer_type();
214214
let sig = match ft.get_wasmtime_signature(pointer_type) {
215-
Some(sig) => sig.clone(),
215+
Some(sig) => sig,
216216
None => bail!("not a supported core wasm signature {:?}", ft),
217217
};
218218

@@ -276,7 +276,7 @@ pub unsafe fn create_handle_with_raw_function(
276276

277277
let pointer_type = isa.pointer_type();
278278
let sig = match ft.get_wasmtime_signature(pointer_type) {
279-
Some(sig) => sig.clone(),
279+
Some(sig) => sig,
280280
None => bail!("not a supported core wasm signature {:?}", ft),
281281
};
282282

crates/c-api/src/extern.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ pub extern "C" fn wasm_extern_kind(e: &wasm_extern_t) -> wasm_externkind_t {
4141
#[no_mangle]
4242
pub extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externtype_t> {
4343
let ty = match &e.which {
44-
ExternHost::Func(f) => ExternType::Func(f.borrow().ty().clone()),
45-
ExternHost::Global(f) => ExternType::Global(f.borrow().ty().clone()),
46-
ExternHost::Table(f) => ExternType::Table(f.borrow().ty().clone()),
47-
ExternHost::Memory(f) => ExternType::Memory(f.borrow().ty().clone()),
44+
ExternHost::Func(f) => ExternType::Func(f.borrow().ty()),
45+
ExternHost::Global(f) => ExternType::Global(f.borrow().ty()),
46+
ExternHost::Table(f) => ExternType::Table(f.borrow().ty()),
47+
ExternHost::Memory(f) => ExternType::Memory(f.borrow().ty()),
4848
};
4949
Box::new(wasm_externtype_t::new(ty))
5050
}

crates/c-api/src/func.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn _wasmtime_func_call(
246246

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

252252
#[no_mangle]
@@ -272,10 +272,10 @@ pub unsafe extern "C" fn wasmtime_caller_export_get(
272272
let name = str::from_utf8(name.as_slice()).ok()?;
273273
let export = caller.caller.get_export(name)?;
274274
let which = match export {
275-
Extern::Func(f) => ExternHost::Func(HostRef::new(f.clone())),
276-
Extern::Global(g) => ExternHost::Global(HostRef::new(g.clone())),
277-
Extern::Memory(m) => ExternHost::Memory(HostRef::new(m.clone())),
278-
Extern::Table(t) => ExternHost::Table(HostRef::new(t.clone())),
275+
Extern::Func(f) => ExternHost::Func(HostRef::new(f)),
276+
Extern::Global(g) => ExternHost::Global(HostRef::new(g)),
277+
Extern::Memory(m) => ExternHost::Memory(HostRef::new(m)),
278+
Extern::Table(t) => ExternHost::Table(HostRef::new(t)),
279279
};
280280
Some(Box::new(wasm_extern_t { which }))
281281
}

crates/c-api/src/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub extern "C" fn wasm_global_as_extern(g: &wasm_global_t) -> &wasm_extern_t {
7171

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

crates/c-api/src/instance.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ pub extern "C" fn wasm_instance_exports(instance: &wasm_instance_t, out: &mut wa
146146
instance
147147
.exports()
148148
.map(|e| match e.external {
149-
Extern::Func(f) => ExternHost::Func(HostRef::new(f.clone())),
150-
Extern::Global(f) => ExternHost::Global(HostRef::new(f.clone())),
151-
Extern::Memory(f) => ExternHost::Memory(HostRef::new(f.clone())),
152-
Extern::Table(f) => ExternHost::Table(HostRef::new(f.clone())),
149+
Extern::Func(f) => ExternHost::Func(HostRef::new(f)),
150+
Extern::Global(f) => ExternHost::Global(HostRef::new(f)),
151+
Extern::Memory(f) => ExternHost::Memory(HostRef::new(f)),
152+
Extern::Table(f) => ExternHost::Table(HostRef::new(f)),
153153
})
154154
.collect()
155155
});

crates/c-api/src/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub extern "C" fn wasm_memory_as_extern(m: &wasm_memory_t) -> &wasm_extern_t {
5151

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

crates/c-api/src/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub unsafe extern "C" fn wasm_table_new(
5454

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

crates/c-api/src/wasi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ pub unsafe extern "C" fn wasi_instance_new(
297297
})),
298298
Err(e) => {
299299
*trap = Box::into_raw(Box::new(wasm_trap_t {
300-
trap: HostRef::new(Trap::new(e.to_string())),
300+
trap: HostRef::new(Trap::new(e)),
301301
}));
302302

303303
None

0 commit comments

Comments
 (0)