Skip to content

Commit

Permalink
Merge #2717
Browse files Browse the repository at this point in the history
2717: Remove internal Arc from Exports r=ptitSeb a=Amanieu

This is useless and prevents cloned Exports from being modified.

Co-authored-by: Amanieu d'Antras <[email protected]>
  • Loading branch information
bors[bot] and Amanieu authored Dec 9, 2021
2 parents fc1a095 + 7b8d4b1 commit 60c58af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
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

0 comments on commit 60c58af

Please sign in to comment.