mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
make bumpmap new functions using a trait
This commit is contained in:
parent
911ad94269
commit
a6fc267449
2 changed files with 22 additions and 3 deletions
|
@ -30,6 +30,26 @@ pub type SendSet<K> = im::hashset::HashSet<K, BuildHasher>;
|
||||||
|
|
||||||
pub type BumpMap<'a, K, V> = hashbrown::HashMap<K, V, BuildHasher, hashbrown::BumpWrapper<'a>>;
|
pub type BumpMap<'a, K, V> = hashbrown::HashMap<K, V, BuildHasher, hashbrown::BumpWrapper<'a>>;
|
||||||
|
|
||||||
|
pub trait BumpMapDefault<'a> {
|
||||||
|
fn new_in(arena: &'a bumpalo::Bump) -> Self;
|
||||||
|
|
||||||
|
fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, K, V> BumpMapDefault<'a> for BumpMap<'a, K, V> {
|
||||||
|
fn new_in(arena: &'a bumpalo::Bump) -> Self {
|
||||||
|
hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self {
|
||||||
|
hashbrown::HashMap::with_capacity_and_hasher_in(
|
||||||
|
capacity,
|
||||||
|
default_hasher(),
|
||||||
|
hashbrown::BumpWrapper(arena),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a>
|
pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a>
|
||||||
where
|
where
|
||||||
I: Iterator<Item = &'a str>,
|
I: Iterator<Item = &'a str>,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::layout::{
|
||||||
};
|
};
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet};
|
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap, MutSet};
|
||||||
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
||||||
use roc_module::low_level::LowLevel;
|
use roc_module::low_level::LowLevel;
|
||||||
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
||||||
|
@ -1833,8 +1833,7 @@ fn specialize_external<'a>(
|
||||||
let host_exposed_layouts = if host_exposed_variables.is_empty() {
|
let host_exposed_layouts = if host_exposed_variables.is_empty() {
|
||||||
HostExposedLayouts::NotHostExposed
|
HostExposedLayouts::NotHostExposed
|
||||||
} else {
|
} else {
|
||||||
let mut aliases =
|
let mut aliases = BumpMap::new_in(env.arena);
|
||||||
hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(env.arena));
|
|
||||||
|
|
||||||
for (symbol, variable) in host_exposed_variables {
|
for (symbol, variable) in host_exposed_variables {
|
||||||
let layout = layout_cache
|
let layout = layout_cache
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue