Skip to content

Commit

Permalink
more btreemap
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Apr 9, 2024
1 parent cd9405a commit 1f48de5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rust/candid/src/types/internal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::CandidType;
use crate::idl_hash;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::fmt;

// This is a re-implementation of std::any::TypeId to get rid of 'static constraint.
Expand Down Expand Up @@ -33,8 +33,8 @@ pub fn type_of<T>(_: &T) -> TypeId {

#[derive(Default)]
struct TypeName {
type_name: HashMap<TypeId, String>,
name_index: HashMap<String, usize>,
type_name: BTreeMap<TypeId, String>,
name_index: BTreeMap<String, usize>,
}
impl TypeName {
fn get(&mut self, id: &TypeId) -> String {
Expand Down Expand Up @@ -626,9 +626,9 @@ pub fn unroll(t: &Type) -> Type {
}

thread_local! {
static ENV: RefCell<HashMap<TypeId, Type>> = RefCell::new(HashMap::new());
static ENV: RefCell<BTreeMap<TypeId, Type>> = RefCell::new(BTreeMap::new());
// only used for TypeContainer
static ID: RefCell<HashMap<Type, TypeId>> = RefCell::new(HashMap::new());
static ID: RefCell<BTreeMap<Type, TypeId>> = RefCell::new(BTreeMap::new());
static NAME: RefCell<TypeName> = RefCell::new(TypeName::default());
}

Expand Down

0 comments on commit 1f48de5

Please sign in to comment.