From 50a967d601749beceaaf901b5931fa0a96fb17df Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 28 Dec 2017 14:47:01 +0000 Subject: [clangd] Simplify code. No functionality change intended. llvm-svn: 321523 --- clang-tools-extra/clangd/index/MemIndex.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'clang-tools-extra/clangd/index/MemIndex.cpp') diff --git a/clang-tools-extra/clangd/index/MemIndex.cpp b/clang-tools-extra/clangd/index/MemIndex.cpp index d0d8084f471..4119e23192f 100644 --- a/clang-tools-extra/clangd/index/MemIndex.cpp +++ b/clang-tools-extra/clangd/index/MemIndex.cpp @@ -26,8 +26,9 @@ void MemIndex::build(std::shared_ptr> Syms) { } } -bool MemIndex::fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req, - std::function Callback) const { +bool MemIndex::fuzzyFind( + const Context &Ctx, const FuzzyFindRequest &Req, + llvm::function_ref Callback) const { assert(!StringRef(Req.Query).contains("::") && "There must be no :: in query."); @@ -38,14 +39,7 @@ bool MemIndex::fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req, const Symbol *Sym = Pair.second; // Exact match against all possible scopes. - bool ScopeMatched = Req.Scopes.empty(); - for (StringRef Scope : Req.Scopes) { - if (Scope == Sym->Scope) { - ScopeMatched = true; - break; - } - } - if (!ScopeMatched) + if (!Req.Scopes.empty() && !llvm::is_contained(Req.Scopes, Sym->Scope)) continue; // FIXME(ioeric): use fuzzy matcher. -- cgit v1.2.3