From e78286c8e88d31045d354320a1d29bbd75405027 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Thu, 10 Jan 2019 02:07:42 +0100 Subject: Save variant names in EnumData to reduce needless queries We already have their names when anyway, and when in all (current) situations where we're interested in an Enum's variants, we want their names. --- crates/ra_ide_api/src/completion/complete_path.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'crates/ra_ide_api/src/completion') diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 6a55670d1..9bfec88d0 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -23,17 +23,12 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C } hir::Def::Enum(e) => { e.variants(ctx.db)? - .unwrap_or(vec![]) .into_iter() - .for_each(|variant| { - let variant_name = variant.name(ctx.db); - - if let Ok(Some(name)) = variant_name { - CompletionItem::new(CompletionKind::Reference, name.to_string()) - .kind(CompletionItemKind::EnumVariant) - .add_to(acc) - } - }) + .for_each(|(variant_name, _variant)| { + CompletionItem::new(CompletionKind::Reference, variant_name.to_string()) + .kind(CompletionItemKind::EnumVariant) + .add_to(acc) + }); } _ => return Ok(()), }; -- cgit v1.2.3