mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 23:11:23 +00:00
Reuse the same parity_wasm::Module
instance for wasmi
Since `wasmi` already has a public dependency on `parity_wasm` let's just use it! A `clone` is much faster than a serialize + parse, reducing a `wasm-bindgen` invocation on my machine from 0.2s to 0.18s.
This commit is contained in:
@ -134,7 +134,9 @@ impl Bindgen {
|
||||
// This means that whenever we encounter an import or export we'll
|
||||
// execute a shim function which informs us about its type so we can
|
||||
// then generate the appropriate bindings.
|
||||
let instance = wasmi::Module::from_buffer(&contents)
|
||||
//
|
||||
// TODO: avoid a `clone` here of the module if we can
|
||||
let instance = wasmi::Module::from_parity_wasm_module(module.clone())
|
||||
.with_context(|_| "failed to create wasmi module")?;
|
||||
let instance = wasmi::ModuleInstance::new(&instance, &MyResolver)
|
||||
.with_context(|_| "failed to instantiate wasm module")?;
|
||||
|
Reference in New Issue
Block a user