Change TypeId to use BTreeMap.

This commit is contained in:
Stephen Chung 2022-09-05 21:17:07 +08:00
parent 0f4df9c4e7
commit 158b4ce7bc
2 changed files with 8 additions and 8 deletions

View File

@ -47,11 +47,11 @@ impl Hasher for StraightHasher {
fn finish(&self) -> u64 { fn finish(&self) -> u64 {
self.0 self.0
} }
#[inline] #[inline(always)]
fn write(&mut self, _bytes: &[u8]) { fn write(&mut self, _bytes: &[u8]) {
panic!("StraightHasher can only hash u64 values"); panic!("StraightHasher can only hash u64 values");
} }
#[inline(always)]
fn write_u64(&mut self, i: u64) { fn write_u64(&mut self, i: u64) {
if i == 0 { if i == 0 {
self.0 = ALT_ZERO_HASH; self.0 = ALT_ZERO_HASH;

View File

@ -278,9 +278,9 @@ pub struct Module {
/// Native Rust functions (in scripted hash format) that contain [`Dynamic`] parameters. /// Native Rust functions (in scripted hash format) that contain [`Dynamic`] parameters.
dynamic_functions: StraightHashSet<u64>, dynamic_functions: StraightHashSet<u64>,
/// Iterator functions, keyed by the type producing the iterator. /// Iterator functions, keyed by the type producing the iterator.
type_iterators: StraightHashMap<TypeId, Shared<IteratorFn>>, type_iterators: BTreeMap<TypeId, Shared<IteratorFn>>,
/// Flattened collection of iterator functions, including those in sub-modules. /// Flattened collection of iterator functions, including those in sub-modules.
all_type_iterators: StraightHashMap<TypeId, Shared<IteratorFn>>, all_type_iterators: BTreeMap<TypeId, Shared<IteratorFn>>,
/// Is the [`Module`] indexed? /// Is the [`Module`] indexed?
indexed: bool, indexed: bool,
/// Does the [`Module`] contain indexed functions that have been exposed to the global namespace? /// Does the [`Module`] contain indexed functions that have been exposed to the global namespace?
@ -378,8 +378,8 @@ impl Module {
functions: StraightHashMap::default(), functions: StraightHashMap::default(),
all_functions: StraightHashMap::default(), all_functions: StraightHashMap::default(),
dynamic_functions: StraightHashSet::default(), dynamic_functions: StraightHashSet::default(),
type_iterators: StraightHashMap::default(), type_iterators: BTreeMap::new(),
all_type_iterators: StraightHashMap::default(), all_type_iterators: BTreeMap::new(),
indexed: true, indexed: true,
contains_indexed_global_functions: false, contains_indexed_global_functions: false,
} }
@ -2141,7 +2141,7 @@ impl Module {
path: &mut Vec<&'a str>, path: &mut Vec<&'a str>,
variables: &mut StraightHashMap<u64, Dynamic>, variables: &mut StraightHashMap<u64, Dynamic>,
functions: &mut StraightHashMap<u64, CallableFunction>, functions: &mut StraightHashMap<u64, CallableFunction>,
type_iterators: &mut StraightHashMap<TypeId, Shared<IteratorFn>>, type_iterators: &mut BTreeMap<TypeId, Shared<IteratorFn>>,
) -> bool { ) -> bool {
let mut contains_indexed_global_functions = false; let mut contains_indexed_global_functions = false;
@ -2205,7 +2205,7 @@ impl Module {
let mut path = Vec::with_capacity(4); let mut path = Vec::with_capacity(4);
let mut variables = StraightHashMap::default(); let mut variables = StraightHashMap::default();
let mut functions = StraightHashMap::default(); let mut functions = StraightHashMap::default();
let mut type_iterators = StraightHashMap::default(); let mut type_iterators = BTreeMap::new();
path.push(""); path.push("");