mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +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
27
Cargo.lock
generated
27
Cargo.lock
generated
|
@ -484,16 +484,6 @@ dependencies = [
|
|||
"unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "im"
|
||||
version = "13.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sized-chunks 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.1.0"
|
||||
|
@ -1016,7 +1006,6 @@ dependencies = [
|
|||
"chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
"chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
"ena 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"im 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1561,14 +1550,6 @@ dependencies = [
|
|||
"yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sized-chunks"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.2"
|
||||
|
@ -1703,11 +1684,6 @@ dependencies = [
|
|||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.5.1"
|
||||
|
@ -1917,7 +1893,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2"
|
||||
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
|
||||
"checksum im 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8db49f8bc08d5cc4e2bb0f7d25a6d1db2c79bc6f7d7c86c96c657eb3d214125f"
|
||||
"checksum indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4d6d89e0948bf10c08b9ecc8ac5b83f07f857ebe2c0cbe38de15b4e4f510356"
|
||||
"checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c"
|
||||
"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718"
|
||||
|
@ -2012,7 +1987,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704"
|
||||
"checksum serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573"
|
||||
"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582"
|
||||
"checksum sized-chunks 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f01db57d7ee89c8e053245deb77040a6cc8508311f381c88749c33d4b9b78785"
|
||||
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||
"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
|
||||
"checksum smol_str 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "590700be3630457c56f8c73c0ea39881476ad7076cd84057d44f4f38f79914fb"
|
||||
|
@ -2028,7 +2002,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
||||
"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"
|
||||
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
|
||||
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
|
||||
"checksum unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150"
|
||||
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
||||
"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
|
||||
|
|
|
@ -6,7 +6,6 @@ authors = ["rust-analyzer developers"]
|
|||
|
||||
[dependencies]
|
||||
arrayvec = "0.4.10"
|
||||
im = "13.0.0"
|
||||
log = "0.4.5"
|
||||
relative-path = "0.4.0"
|
||||
rustc-hash = "1.0"
|
||||
|
|
|
@ -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…
Reference in a new issue