diff --git a/compiler/can/src/effect_module.rs b/compiler/can/src/effect_module.rs index 1c2f76d951..20cf8a9e3e 100644 --- a/compiler/can/src/effect_module.rs +++ b/compiler/can/src/effect_module.rs @@ -4,7 +4,7 @@ use crate::env::Env; use crate::expr::{ClosureData, Expr, Recursive}; use crate::pattern::Pattern; use crate::scope::Scope; -use roc_collections::all::{MutSet, SendMap}; +use roc_collections::all::{SendMap, VecSet}; use roc_module::called_via::CalledVia; use roc_module::ident::TagName; use roc_module::symbol::Symbol; @@ -39,7 +39,7 @@ pub(crate) fn build_effect_builtins( scope: &mut Scope, effect_symbol: Symbol, var_store: &mut VarStore, - exposed_symbols: &mut MutSet, + exposed_symbols: &mut VecSet, declarations: &mut Vec, generated_functions: HostedGeneratedFunctions, ) { diff --git a/compiler/can/src/module.rs b/compiler/can/src/module.rs index f6f8ce853b..bc1961acbf 100644 --- a/compiler/can/src/module.rs +++ b/compiler/can/src/module.rs @@ -23,7 +23,7 @@ use roc_types::types::{Alias, AliasKind, Type}; pub struct Module { pub module_id: ModuleId, pub exposed_imports: MutMap, - pub exposed_symbols: MutSet, + pub exposed_symbols: VecSet, pub referenced_values: VecSet, pub referenced_types: VecSet, /// all aliases. `bool` indicates whether it is exposed @@ -89,7 +89,7 @@ pub fn canonicalize_module_defs<'a>( dep_idents: &'a MutMap, aliases: MutMap, exposed_imports: MutMap, - exposed_symbols: &MutSet, + exposed_symbols: &VecSet, var_store: &mut VarStore, ) -> Result { let mut can_exposed_imports = MutMap::default(); @@ -319,7 +319,7 @@ pub fn canonicalize_module_defs<'a>( generated_functions, }) = hosted_info { - let mut exposed_symbols = MutSet::default(); + let mut exposed_symbols = VecSet::default(); // NOTE this currently builds all functions, not just the ones that the user requested crate::effect_module::build_effect_builtins( diff --git a/compiler/collections/src/all.rs b/compiler/collections/src/all.rs index 01860a9e7f..879c2783a9 100644 --- a/compiler/collections/src/all.rs +++ b/compiler/collections/src/all.rs @@ -235,6 +235,12 @@ impl Default for VecSet { } impl VecSet { + pub fn with_capacity(capacity: usize) -> Self { + Self { + elements: Vec::with_capacity(capacity), + } + } + pub fn insert(&mut self, value: T) -> bool { if self.elements.contains(&value) { true diff --git a/compiler/load_internal/src/file.rs b/compiler/load_internal/src/file.rs index 6c52590996..37ed5b1269 100644 --- a/compiler/load_internal/src/file.rs +++ b/compiler/load_internal/src/file.rs @@ -9,7 +9,7 @@ use roc_can::abilities::AbilitiesStore; use roc_can::constraint::{Constraint as ConstraintSoa, Constraints}; use roc_can::def::Declaration; use roc_can::module::{canonicalize_module_defs, Module}; -use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet}; +use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet, VecSet}; use roc_constrain::module::{ constrain_builtin_imports, constrain_module, ExposedByModule, ExposedForModule, ExposedModuleTypes, @@ -40,7 +40,7 @@ use roc_types::solved_types::Solved; use roc_types::subs::{Subs, VarStore, Variable}; use roc_types::types::{Alias, AliasCommon, TypeExtension}; use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::collections::{HashMap, HashSet}; +use std::collections::{HashMap, }; use std::io; use std::iter; use std::ops::ControlFlow; @@ -605,7 +605,7 @@ struct State<'a> { pub declarations_by_id: MutMap>, - pub exposed_symbols_by_module: MutMap>, + pub exposed_symbols_by_module: MutMap>, pub timings: MutMap, @@ -749,7 +749,7 @@ enum BuildTask<'a> { parsed: ParsedModule<'a>, module_ids: ModuleIds, dep_idents: MutMap, - exposed_symbols: MutSet, + exposed_symbols: VecSet, aliases: MutMap, }, Solve { @@ -1680,8 +1680,7 @@ fn update<'a>( } // This was a dependency. Write it down and keep processing messages. - let mut exposed_symbols: MutSet = - HashSet::with_capacity_and_hasher(header.exposes.len(), default_hasher()); + let mut exposed_symbols: VecSet = VecSet::with_capacity(header.exposes.len()); // TODO can we avoid this loop by storing them as a Set in Header to begin with? for symbol in header.exposes.iter() { @@ -3399,7 +3398,7 @@ fn canonicalize_and_constrain<'a>( arena: &'a Bump, module_ids: &ModuleIds, dep_idents: MutMap, - exposed_symbols: MutSet, + exposed_symbols: VecSet, aliases: MutMap, parsed: ParsedModule<'a>, ) -> Result, LoadingProblem<'a>> {