Use FxHashMap

This commit is contained in:
Florian Diebold 2020-01-10 18:59:57 +01:00 committed by Florian Diebold
parent 4496e2a06a
commit ccb75f7c97
3 changed files with 5 additions and 3 deletions

1
Cargo.lock generated
View file

@ -872,6 +872,7 @@ dependencies = [
"ra_hir 0.1.0",
"ra_syntax 0.1.0",
"ra_text_edit 0.1.0",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]

View file

@ -10,6 +10,7 @@ doctest = false
[dependencies]
format-buf = "1.0.0"
join_to_string = "0.1.3"
rustc-hash = "1.0"
itertools = "0.8.0"
ra_syntax = { path = "../ra_syntax" }

View file

@ -1,5 +1,5 @@
//! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined.
use std::collections::HashMap;
use rustc_hash::FxHashMap;
use hir::{db::HirDatabase, InFile, PathResolution};
use ra_syntax::ast::{self, make, AstNode};
@ -35,7 +35,7 @@ impl<'a> AstTransform<'a> for NullTransformer {
pub struct SubstituteTypeParams<'a, DB: HirDatabase> {
db: &'a DB,
substs: HashMap<hir::TypeParam, ast::TypeRef>,
substs: FxHashMap<hir::TypeParam, ast::TypeRef>,
previous: Box<dyn AstTransform<'a> + 'a>,
}
@ -47,7 +47,7 @@ impl<'a, DB: HirDatabase> SubstituteTypeParams<'a, DB> {
) -> SubstituteTypeParams<'a, DB> {
let substs = get_syntactic_substs(impl_block).unwrap_or_default();
let generic_def: hir::GenericDef = trait_.into();
let substs_by_param: HashMap<_, _> = generic_def
let substs_by_param: FxHashMap<_, _> = generic_def
.params(db)
.into_iter()
// this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky