mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
use VecSet for exposed_symbols
This commit is contained in:
parent
39aa112fd5
commit
304b7fd569
4 changed files with 17 additions and 12 deletions
|
@ -4,7 +4,7 @@ use crate::env::Env;
|
||||||
use crate::expr::{ClosureData, Expr, Recursive};
|
use crate::expr::{ClosureData, Expr, Recursive};
|
||||||
use crate::pattern::Pattern;
|
use crate::pattern::Pattern;
|
||||||
use crate::scope::Scope;
|
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::called_via::CalledVia;
|
||||||
use roc_module::ident::TagName;
|
use roc_module::ident::TagName;
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
|
@ -39,7 +39,7 @@ pub(crate) fn build_effect_builtins(
|
||||||
scope: &mut Scope,
|
scope: &mut Scope,
|
||||||
effect_symbol: Symbol,
|
effect_symbol: Symbol,
|
||||||
var_store: &mut VarStore,
|
var_store: &mut VarStore,
|
||||||
exposed_symbols: &mut MutSet<Symbol>,
|
exposed_symbols: &mut VecSet<Symbol>,
|
||||||
declarations: &mut Vec<Declaration>,
|
declarations: &mut Vec<Declaration>,
|
||||||
generated_functions: HostedGeneratedFunctions,
|
generated_functions: HostedGeneratedFunctions,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ use roc_types::types::{Alias, AliasKind, Type};
|
||||||
pub struct Module {
|
pub struct Module {
|
||||||
pub module_id: ModuleId,
|
pub module_id: ModuleId,
|
||||||
pub exposed_imports: MutMap<Symbol, Variable>,
|
pub exposed_imports: MutMap<Symbol, Variable>,
|
||||||
pub exposed_symbols: MutSet<Symbol>,
|
pub exposed_symbols: VecSet<Symbol>,
|
||||||
pub referenced_values: VecSet<Symbol>,
|
pub referenced_values: VecSet<Symbol>,
|
||||||
pub referenced_types: VecSet<Symbol>,
|
pub referenced_types: VecSet<Symbol>,
|
||||||
/// all aliases. `bool` indicates whether it is exposed
|
/// all aliases. `bool` indicates whether it is exposed
|
||||||
|
@ -89,7 +89,7 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
dep_idents: &'a MutMap<ModuleId, IdentIds>,
|
dep_idents: &'a MutMap<ModuleId, IdentIds>,
|
||||||
aliases: MutMap<Symbol, Alias>,
|
aliases: MutMap<Symbol, Alias>,
|
||||||
exposed_imports: MutMap<Ident, (Symbol, Region)>,
|
exposed_imports: MutMap<Ident, (Symbol, Region)>,
|
||||||
exposed_symbols: &MutSet<Symbol>,
|
exposed_symbols: &VecSet<Symbol>,
|
||||||
var_store: &mut VarStore,
|
var_store: &mut VarStore,
|
||||||
) -> Result<ModuleOutput, RuntimeError> {
|
) -> Result<ModuleOutput, RuntimeError> {
|
||||||
let mut can_exposed_imports = MutMap::default();
|
let mut can_exposed_imports = MutMap::default();
|
||||||
|
@ -319,7 +319,7 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
generated_functions,
|
generated_functions,
|
||||||
}) = hosted_info
|
}) = 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
|
// NOTE this currently builds all functions, not just the ones that the user requested
|
||||||
crate::effect_module::build_effect_builtins(
|
crate::effect_module::build_effect_builtins(
|
||||||
|
|
|
@ -235,6 +235,12 @@ impl<T> Default for VecSet<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: PartialEq> VecSet<T> {
|
impl<T: PartialEq> VecSet<T> {
|
||||||
|
pub fn with_capacity(capacity: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
elements: Vec::with_capacity(capacity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert(&mut self, value: T) -> bool {
|
pub fn insert(&mut self, value: T) -> bool {
|
||||||
if self.elements.contains(&value) {
|
if self.elements.contains(&value) {
|
||||||
true
|
true
|
||||||
|
|
|
@ -9,7 +9,7 @@ use roc_can::abilities::AbilitiesStore;
|
||||||
use roc_can::constraint::{Constraint as ConstraintSoa, Constraints};
|
use roc_can::constraint::{Constraint as ConstraintSoa, Constraints};
|
||||||
use roc_can::def::Declaration;
|
use roc_can::def::Declaration;
|
||||||
use roc_can::module::{canonicalize_module_defs, Module};
|
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::{
|
use roc_constrain::module::{
|
||||||
constrain_builtin_imports, constrain_module, ExposedByModule, ExposedForModule,
|
constrain_builtin_imports, constrain_module, ExposedByModule, ExposedForModule,
|
||||||
ExposedModuleTypes,
|
ExposedModuleTypes,
|
||||||
|
@ -40,7 +40,7 @@ use roc_types::solved_types::Solved;
|
||||||
use roc_types::subs::{Subs, VarStore, Variable};
|
use roc_types::subs::{Subs, VarStore, Variable};
|
||||||
use roc_types::types::{Alias, AliasCommon, TypeExtension};
|
use roc_types::types::{Alias, AliasCommon, TypeExtension};
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, };
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
@ -605,7 +605,7 @@ struct State<'a> {
|
||||||
|
|
||||||
pub declarations_by_id: MutMap<ModuleId, Vec<Declaration>>,
|
pub declarations_by_id: MutMap<ModuleId, Vec<Declaration>>,
|
||||||
|
|
||||||
pub exposed_symbols_by_module: MutMap<ModuleId, MutSet<Symbol>>,
|
pub exposed_symbols_by_module: MutMap<ModuleId, VecSet<Symbol>>,
|
||||||
|
|
||||||
pub timings: MutMap<ModuleId, ModuleTiming>,
|
pub timings: MutMap<ModuleId, ModuleTiming>,
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ enum BuildTask<'a> {
|
||||||
parsed: ParsedModule<'a>,
|
parsed: ParsedModule<'a>,
|
||||||
module_ids: ModuleIds,
|
module_ids: ModuleIds,
|
||||||
dep_idents: MutMap<ModuleId, IdentIds>,
|
dep_idents: MutMap<ModuleId, IdentIds>,
|
||||||
exposed_symbols: MutSet<Symbol>,
|
exposed_symbols: VecSet<Symbol>,
|
||||||
aliases: MutMap<Symbol, Alias>,
|
aliases: MutMap<Symbol, Alias>,
|
||||||
},
|
},
|
||||||
Solve {
|
Solve {
|
||||||
|
@ -1680,8 +1680,7 @@ fn update<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// This was a dependency. Write it down and keep processing messages.
|
// This was a dependency. Write it down and keep processing messages.
|
||||||
let mut exposed_symbols: MutSet<Symbol> =
|
let mut exposed_symbols: VecSet<Symbol> = VecSet::with_capacity(header.exposes.len());
|
||||||
HashSet::with_capacity_and_hasher(header.exposes.len(), default_hasher());
|
|
||||||
|
|
||||||
// TODO can we avoid this loop by storing them as a Set in Header to begin with?
|
// TODO can we avoid this loop by storing them as a Set in Header to begin with?
|
||||||
for symbol in header.exposes.iter() {
|
for symbol in header.exposes.iter() {
|
||||||
|
@ -3399,7 +3398,7 @@ fn canonicalize_and_constrain<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
module_ids: &ModuleIds,
|
module_ids: &ModuleIds,
|
||||||
dep_idents: MutMap<ModuleId, IdentIds>,
|
dep_idents: MutMap<ModuleId, IdentIds>,
|
||||||
exposed_symbols: MutSet<Symbol>,
|
exposed_symbols: VecSet<Symbol>,
|
||||||
aliases: MutMap<Symbol, Alias>,
|
aliases: MutMap<Symbol, Alias>,
|
||||||
parsed: ParsedModule<'a>,
|
parsed: ParsedModule<'a>,
|
||||||
) -> Result<Msg<'a>, LoadingProblem<'a>> {
|
) -> Result<Msg<'a>, LoadingProblem<'a>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue