Remove internal Arc from Exports

This is useless and prevents cloned Exports from being modified.
This commit is contained in:
Amanieu d'Antras
2021-12-09 17:56:28 +00:00
parent a5fd71b63f
commit 7b8d4b1c8e
2 changed files with 8 additions and 14 deletions

View File

@@ -6,7 +6,6 @@ use crate::js::WasmTypeList;
use indexmap::IndexMap;
use std::fmt;
use std::iter::{ExactSizeIterator, FromIterator};
use std::sync::Arc;
use thiserror::Error;
/// The `ExportError` can happen when trying to get a specific
@@ -63,7 +62,7 @@ pub enum ExportError {
/// TODO: add examples of using exports
#[derive(Clone, Default)]
pub struct Exports {
map: Arc<IndexMap<String, Extern>>,
map: IndexMap<String, Extern>,
}
impl Exports {
@@ -75,7 +74,7 @@ impl Exports {
/// Creates a new `Exports` with capacity `n`.
pub fn with_capacity(n: usize) -> Self {
Self {
map: Arc::new(IndexMap::with_capacity(n)),
map: IndexMap::with_capacity(n),
}
}
@@ -95,9 +94,7 @@ impl Exports {
S: Into<String>,
E: Into<Extern>,
{
Arc::get_mut(&mut self.map)
.unwrap()
.insert(name.into(), value.into());
self.map.insert(name.into(), value.into());
}
/// Get an export given a `name`.
@@ -272,7 +269,7 @@ where
impl FromIterator<(String, Extern)> for Exports {
fn from_iter<I: IntoIterator<Item = (String, Extern)>>(iter: I) -> Self {
Self {
map: Arc::new(IndexMap::from_iter(iter)),
map: IndexMap::from_iter(iter),
}
}
}