Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal Arc from Exports #2717

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/api/src/js/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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),
}
}

Expand All @@ -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`.
Expand Down Expand Up @@ -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),
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions lib/api/src/sys/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use indexmap::IndexMap;
use loupe::MemoryUsage;
use std::fmt;
use std::iter::{ExactSizeIterator, FromIterator};
use std::sync::Arc;
use thiserror::Error;
use wasmer_engine::Export;

Expand Down Expand Up @@ -64,7 +63,7 @@ pub enum ExportError {
/// TODO: add examples of using exports
#[derive(Clone, Default, MemoryUsage)]
pub struct Exports {
map: Arc<IndexMap<String, Extern>>,
map: IndexMap<String, Extern>,
}

impl Exports {
Expand All @@ -76,7 +75,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),
}
}

Expand All @@ -96,9 +95,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`.
Expand Down Expand Up @@ -274,7 +271,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),
}
}
}
Expand Down