kbobyrev created this revision. kbobyrev added reviewers: ioeric, ilya-biryukov, sammccall. kbobyrev added a project: clang-tools-extra. Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
`AND( AND( Child ) ... )` -> `AND( Child ... )` `AND( OR( Child) ... )` -> `AND( Child ... )` This simple optimization results in 5-6% performance improvement in the benchmark with 2000 serialized `FuzzyFindRequest`s. https://reviews.llvm.org/D52016 Files: clang-tools-extra/clangd/index/dex/Dex.cpp Index: clang-tools-extra/clangd/index/dex/Dex.cpp =================================================================== --- clang-tools-extra/clangd/index/dex/Dex.cpp +++ clang-tools-extra/clangd/index/dex/Dex.cpp @@ -144,8 +144,10 @@ if (It != InvertedIndex.end()) TrigramIterators.push_back(create(It->second)); } - if (!TrigramIterators.empty()) + if (TrigramIterators.size() > 1) TopLevelChildren.push_back(createAnd(move(TrigramIterators))); + else if (TrigramIterators.size() == 1) + TopLevelChildren.push_back(move(TrigramIterators.front())); // Generate scope tokens for search query. std::vector<std::unique_ptr<Iterator>> ScopeIterators; @@ -155,8 +157,10 @@ ScopeIterators.push_back(create(It->second)); } // Add OR iterator for scopes if there are any Scope Iterators. - if (!ScopeIterators.empty()) + if (ScopeIterators.size() > 1) TopLevelChildren.push_back(createOr(move(ScopeIterators))); + else if (ScopeIterators.size() == 1) + TopLevelChildren.push_back(move(ScopeIterators.front())); // Add proximity paths boosting. auto BoostingIterators = createFileProximityIterators(
Index: clang-tools-extra/clangd/index/dex/Dex.cpp =================================================================== --- clang-tools-extra/clangd/index/dex/Dex.cpp +++ clang-tools-extra/clangd/index/dex/Dex.cpp @@ -144,8 +144,10 @@ if (It != InvertedIndex.end()) TrigramIterators.push_back(create(It->second)); } - if (!TrigramIterators.empty()) + if (TrigramIterators.size() > 1) TopLevelChildren.push_back(createAnd(move(TrigramIterators))); + else if (TrigramIterators.size() == 1) + TopLevelChildren.push_back(move(TrigramIterators.front())); // Generate scope tokens for search query. std::vector<std::unique_ptr<Iterator>> ScopeIterators; @@ -155,8 +157,10 @@ ScopeIterators.push_back(create(It->second)); } // Add OR iterator for scopes if there are any Scope Iterators. - if (!ScopeIterators.empty()) + if (ScopeIterators.size() > 1) TopLevelChildren.push_back(createOr(move(ScopeIterators))); + else if (ScopeIterators.size() == 1) + TopLevelChildren.push_back(move(ScopeIterators.front())); // Add proximity paths boosting. auto BoostingIterators = createFileProximityIterators(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits