aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
authoruHOOCCOOHu <[email protected]>2019-09-07 15:46:44 +0100
committeruHOOCCOOHu <[email protected]>2019-09-08 18:34:53 +0100
commitc90256429bf41958ff6c7390dfd5fa25123eabb3 (patch)
treed6b027eb4290795d158ea0463c9bc5f4d887e655 /crates/ra_hir/src/nameres.rs
parent26b092bd3b431559d7aafbf42882f978c0bb3dab (diff)
Replace with immutable map to avoid heavy cloning
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index befbb2a9b..7e5138d05 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -54,6 +54,7 @@ mod mod_resolution;
54#[cfg(test)] 54#[cfg(test)]
55mod tests; 55mod tests;
56 56
57use std::hash::BuildHasherDefault;
57use std::sync::Arc; 58use std::sync::Arc;
58 59
59use once_cell::sync::Lazy; 60use once_cell::sync::Lazy;
@@ -61,7 +62,7 @@ use ra_arena::{impl_arena_id, Arena, RawId};
61use ra_db::{Edition, FileId}; 62use ra_db::{Edition, FileId};
62use ra_prof::profile; 63use ra_prof::profile;
63use ra_syntax::ast; 64use ra_syntax::ast;
64use rustc_hash::{FxHashMap, FxHashSet}; 65use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
65use test_utils::tested_by; 66use test_utils::tested_by;
66 67
67use crate::{ 68use crate::{
@@ -73,6 +74,8 @@ use crate::{
73 AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait, 74 AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
74}; 75};
75 76
77pub(crate) type ImmFxHashMap<K, V> = im::HashMap<K, V, BuildHasherDefault<FxHasher>>;
78
76pub(crate) use self::raw::{ImportSourceMap, RawItems}; 79pub(crate) use self::raw::{ImportSourceMap, RawItems};
77 80
78pub use self::{ 81pub use self::{
@@ -139,7 +142,7 @@ pub(crate) struct ModuleData {
139pub struct ModuleScope { 142pub struct ModuleScope {
140 items: FxHashMap<Name, Resolution>, 143 items: FxHashMap<Name, Resolution>,
141 macros: FxHashMap<Name, MacroDef>, 144 macros: FxHashMap<Name, MacroDef>,
142 textual_macros: FxHashMap<Name, MacroDef>, 145 textual_macros: ImmFxHashMap<Name, MacroDef>,
143} 146}
144 147
145static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| { 148static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| {