mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Use delete_typed
to improve some ergonomics
This commit is contained in:
parent
e8e84a3f9c
commit
22b26db911
@ -475,24 +475,22 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
let mut descriptor_section = None;
|
||||
for (id, section) in self.module.customs.iter_mut() {
|
||||
let custom = match section
|
||||
.as_any_mut()
|
||||
.downcast_mut::<WasmBindgenDescriptorsSection>()
|
||||
{
|
||||
Some(s) => s,
|
||||
None => continue,
|
||||
};
|
||||
descriptor_section = Some(id);
|
||||
|
||||
if let Some(custom) = self
|
||||
.module
|
||||
.customs
|
||||
.delete_typed::<WasmBindgenDescriptorsSection>()
|
||||
{
|
||||
let WasmBindgenDescriptorsSection {
|
||||
descriptors,
|
||||
closure_imports,
|
||||
} = *custom;
|
||||
// Store all the executed descriptors in our own field so we have
|
||||
// access to them while processing programs.
|
||||
self.descriptors.extend(custom.descriptors.drain());
|
||||
self.descriptors.extend(descriptors);
|
||||
|
||||
// Register all the injected closure imports as that they're expected
|
||||
// to manufacture a particular type of closure.
|
||||
for (id, descriptor) in custom.closure_imports.drain() {
|
||||
for (id, descriptor) in closure_imports {
|
||||
self.aux
|
||||
.import_map
|
||||
.insert(id, AuxImport::Closure(descriptor));
|
||||
@ -506,9 +504,6 @@ impl<'a> Context<'a> {
|
||||
.insert(id, ImportBinding::Function(binding));
|
||||
}
|
||||
}
|
||||
if let Some(id) = descriptor_section {
|
||||
self.module.customs.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
fn program(&mut self, program: decode::Program<'a>) -> Result<(), Error> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user