From 76f3d277a67431b14b7904b1ea4e6cc4f48e96dc Mon Sep 17 00:00:00 2001 From: Maxim Pimenov Date: Tue, 3 Sep 2019 15:16:53 +0300 Subject: [PATCH] [search] [bookmarks] Limited the number of bookmark results. --- search/bookmarks/processor.cpp | 6 ++++++ search/bookmarks/processor.hpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/search/bookmarks/processor.cpp b/search/bookmarks/processor.cpp index a81f830c40..074202f0a9 100644 --- a/search/bookmarks/processor.cpp +++ b/search/bookmarks/processor.cpp @@ -261,8 +261,14 @@ void Processor::Search(Params const & params) const BailIfCancelled(); sort(idInfos.begin(), idInfos.end()); + size_t numEmitted = 0; for (auto const & idInfo : idInfos) + { + if (numEmitted >= params.m_maxNumResults) + break; m_emitter.AddBookmarkResult(bookmarks::Result(idInfo.m_id)); + ++numEmitted; + } } uint64_t Processor::GetNumDocs(strings::UniString const & token, bool isPrefix) const diff --git a/search/bookmarks/processor.hpp b/search/bookmarks/processor.hpp index 4c6c88d808..9f7ec2f202 100644 --- a/search/bookmarks/processor.hpp +++ b/search/bookmarks/processor.hpp @@ -8,6 +8,7 @@ #include "search/feature_offset_match.hpp" #include "search/idf_map.hpp" #include "search/query_params.hpp" +#include "search/search_params.hpp" #include "search/utils.hpp" #include "indexer/search_string_utils.hpp" @@ -38,6 +39,8 @@ public: { // If valid, only show results with bookmarks attached to |m_groupId|. GroupId m_groupId = kInvalidGroupId; + + size_t m_maxNumResults = SearchParams::kDefaultNumResultsEverywhere; }; Processor(Emitter & emitter, base::Cancellable const & cancellable);