Change HashMap to BTreeMap.

This commit is contained in:
Stephen Chung
2021-03-23 12:13:53 +08:00
parent 7a0032fc89
commit f70225ca1d
19 changed files with 139 additions and 214 deletions

View File

@@ -880,7 +880,7 @@ impl Engine {
#[cfg(not(feature = "no_module"))]
pub fn register_static_module(&mut self, name: &str, module: Shared<Module>) -> &mut Self {
fn register_static_module_raw(
root: &mut crate::stdlib::collections::HashMap<crate::ImmutableString, Shared<Module>>,
root: &mut crate::stdlib::collections::BTreeMap<crate::ImmutableString, Shared<Module>>,
name: &str,
module: Shared<Module>,
) {
@@ -1012,14 +1012,14 @@ impl Engine {
ast::{ASTNode, Expr, Stmt},
fn_native::shared_take_or_clone,
module::resolvers::StaticModuleResolver,
stdlib::collections::HashSet,
stdlib::collections::BTreeSet,
ImmutableString,
};
fn collect_imports(
ast: &AST,
resolver: &StaticModuleResolver,
imports: &mut HashSet<ImmutableString>,
imports: &mut BTreeSet<ImmutableString>,
) {
ast.walk(&mut |path| match path.last().unwrap() {
// Collect all `import` statements with a string constant path
@@ -1035,7 +1035,7 @@ impl Engine {
let mut resolver = StaticModuleResolver::new();
let mut ast = self.compile_scripts_with_scope(scope, &[script])?;
let mut imports = HashSet::<ImmutableString>::new();
let mut imports = Default::default();
collect_imports(&ast, &mut resolver, &mut imports);