From fdd721e9ef4d330351769a7498d459a198bf0a0b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 19:35:24 +0200 Subject: Improve indexing of impls Store impls for e.g. &Foo with the ones for Foo instead of the big "other" bucket. This can improve performance and simplifies the HIR impl search a bit. --- crates/hir/src/lib.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 04875240b..eba46a056 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1580,11 +1580,24 @@ impl Impl { ty.equals_ctor(rref.as_ref().map_or(&self_ty.ty, |it| &it.ty)) }; + let fp = TyFingerprint::for_inherent_impl(&ty); + let fp = if let Some(fp) = fp { + fp + } else { + return Vec::new(); + }; + let mut all = Vec::new(); def_crates.iter().for_each(|&id| { - all.extend(db.inherent_impls_in_crate(id).all_impls().map(Self::from).filter(filter)) + all.extend( + db.inherent_impls_in_crate(id) + .for_self_ty(&ty) + .into_iter() + .cloned() + .map(Self::from) + .filter(filter), + ) }); - let fp = TyFingerprint::for_impl(&ty); for id in def_crates .iter() .flat_map(|&id| Crate { id }.transitive_reverse_dependencies(db)) @@ -1592,13 +1605,12 @@ impl Impl { .chain(def_crates.iter().copied()) .unique() { - match fp { - Some(fp) => all.extend( - db.trait_impls_in_crate(id).for_self_ty(fp).map(Self::from).filter(filter), - ), - None => all - .extend(db.trait_impls_in_crate(id).all_impls().map(Self::from).filter(filter)), - } + all.extend( + db.trait_impls_in_crate(id) + .for_self_ty_without_blanket_impls(fp) + .map(Self::from) + .filter(filter), + ); } all } -- cgit v1.2.3