Skip to content

Commit

Permalink
Use ordered IndexMap for exports in runtime-core
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Aug 1, 2019
1 parent 676bccf commit 052ad13
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ page_size = "0.4.1"
wasmparser = "0.35.1"
parking_lot = "0.9.0"
lazy_static = "1.3.0"
indexmap = "1.0.2"
errno = "0.2.4"
libc = "0.2.60"
hex = "0.3.2"
smallvec = "0.6.10"
bincode = "1.1"
colored = "1.8"

[dependencies.indexmap]
version = "1.0.2"
features = ["serde-1"]

# Dependencies for caching.
[dependencies.serde]
version = "1.0.98"
Expand Down
4 changes: 2 additions & 2 deletions lib/runtime-core/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
global::Global, instance::InstanceInner, memory::Memory, module::ExportIndex,
module::ModuleInner, table::Table, types::FuncSig, vm,
};
use std::collections::hash_map;
use indexmap::map::Iter as IndexMapIter;
use std::sync::Arc;

#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -41,7 +41,7 @@ impl FuncPointer {

pub struct ExportIter<'a> {
inner: &'a InstanceInner,
iter: hash_map::Iter<'a, String, ExportIndex>,
iter: IndexMapIter<'a, String, ExportIndex>,
module: &'a ModuleInner,
}

Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-core/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct ModuleInfo {
pub imported_tables: Map<ImportedTableIndex, (ImportName, TableDescriptor)>,
pub imported_globals: Map<ImportedGlobalIndex, (ImportName, GlobalDescriptor)>,

pub exports: HashMap<String, ExportIndex>,
pub exports: IndexMap<String, ExportIndex>,

pub data_initializers: Vec<DataInitializer>,
pub elem_initializers: Vec<TableInitializer>,
Expand Down
3 changes: 2 additions & 1 deletion lib/runtime-core/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ mod vm_ctx_tests {
use crate::cache::Error as CacheError;
use crate::typed_func::Wasm;
use crate::types::{LocalFuncIndex, SigIndex};
use indexmap::IndexMap;
use std::any::Any;
use std::collections::HashMap;
use std::ptr::NonNull;
Expand Down Expand Up @@ -890,7 +891,7 @@ mod vm_ctx_tests {
imported_tables: Map::new(),
imported_globals: Map::new(),

exports: HashMap::new(),
exports: IndexMap::new(),

data_initializers: Vec::new(),
elem_initializers: Vec::new(),
Expand Down

0 comments on commit 052ad13

Please sign in to comment.