mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Revert "Replace with immutable map to avoid heavy cloning"
This reverts commit 2c494eb803c88ef5d23607c3b156fce60c2b8076. See: https://github.com/rust-analyzer/rust-analyzer/pull/1784#issuecomment-529119924
This commit is contained in:
parent
c90256429b
commit
f7f7c2aff8
4 changed files with 2 additions and 36 deletions
|
@ -54,7 +54,6 @@ mod mod_resolution;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use std::hash::BuildHasherDefault;
|
||||
use std::sync::Arc;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
|
@ -62,7 +61,7 @@ use ra_arena::{impl_arena_id, Arena, RawId};
|
|||
use ra_db::{Edition, FileId};
|
||||
use ra_prof::profile;
|
||||
use ra_syntax::ast;
|
||||
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use test_utils::tested_by;
|
||||
|
||||
use crate::{
|
||||
|
@ -74,8 +73,6 @@ use crate::{
|
|||
AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
|
||||
};
|
||||
|
||||
pub(crate) type ImmFxHashMap<K, V> = im::HashMap<K, V, BuildHasherDefault<FxHasher>>;
|
||||
|
||||
pub(crate) use self::raw::{ImportSourceMap, RawItems};
|
||||
|
||||
pub use self::{
|
||||
|
@ -142,7 +139,7 @@ pub(crate) struct ModuleData {
|
|||
pub struct ModuleScope {
|
||||
items: FxHashMap<Name, Resolution>,
|
||||
macros: FxHashMap<Name, MacroDef>,
|
||||
textual_macros: ImmFxHashMap<Name, MacroDef>,
|
||||
textual_macros: FxHashMap<Name, MacroDef>,
|
||||
}
|
||||
|
||||
static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| {
|
||||
|
|
|
@ -631,7 +631,6 @@ where
|
|||
modules[res].parent = Some(self.module_id);
|
||||
modules[res].declaration = Some(declaration);
|
||||
modules[res].definition = definition;
|
||||
// Cloning immutable map is lazy and fast
|
||||
modules[res].scope.textual_macros = modules[self.module_id].scope.textual_macros.clone();
|
||||
modules[self.module_id].children.insert(name.clone(), res);
|
||||
let resolution = Resolution {
|
||||
|
@ -708,8 +707,6 @@ where
|
|||
}
|
||||
|
||||
fn import_all_textual_macros(&mut self, module_id: CrateModuleId) {
|
||||
// `clone()` is needed here to avoid mutable borrow `self.def_collector` when first borrow is alive
|
||||
// Cloning immutable map is lazy and fast
|
||||
let macros = self.def_collector.def_map[module_id].scope.textual_macros.clone();
|
||||
for (name, macro_) in macros {
|
||||
self.def_collector.define_textual_macro(self.module_id, name.clone(), macro_.id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue