Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Do not allocate for `wasmtime::Module::imports` iterator (#12682)

Nick Fitzgerald31f450798195
diff --git a/crates/wasmtime/src/runtime/module.rs b/crates/wasmtime/src/runtime/module.rs
index 4625d1aabc..ada8d58a06 100644
--- a/crates/wasmtime/src/runtime/module.rs
+++ b/crates/wasmtime/src/runtime/module.rs
@@ -755,14 +755,10 @@ impl Module {
let module = self.compiled_module().module();
let types = self.types();
let engine = self.engine();
- module
- .imports()
- .map(move |(imp_mod, imp_field, ty)| {
- debug_assert!(ty.is_canonicalized_for_runtime_usage());
- ImportType::new(imp_mod, imp_field, ty, types, engine)
- })
- .collect::<Vec<_>>()
- .into_iter()
+ module.imports().map(move |(imp_mod, imp_field, ty)| {
+ debug_assert!(ty.is_canonicalized_for_runtime_usage());
+ ImportType::new(imp_mod, imp_field, ty, types, engine)
+ })
}
/// Returns the list of exports that this [`Module`] has and will be