Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: components/omnibox/browser/url_index_private_data.cc

Issue 2842513006: Omnibox - HistoryQuick Provider - Don't Run Duplicate Searches (Closed)
Patch Set: use set of vectors instead Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/url_index_private_data.cc
diff --git a/components/omnibox/browser/url_index_private_data.cc b/components/omnibox/browser/url_index_private_data.cc
index b9f2a93ea945bc2e73e33afdb396d0bd0ef8a975..f5612576bed7a5ef7f71a0d6bb52894fb987264c 100644
--- a/components/omnibox/browser/url_index_private_data.cc
+++ b/components/omnibox/browser/url_index_private_data.cc
@@ -10,6 +10,7 @@
#include <iterator>
#include <limits>
#include <numeric>
+#include <set>
#include <string>
#include <vector>
@@ -173,6 +174,9 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
ResetSearchTermCache();
bool history_ids_were_trimmed = false;
+ // A set containing the list of words extracted from each search string,
+ // used to prevent running duplicate searches.
+ std::set<String16Vector> search_string_words;
for (const base::string16& search_string : search_strings) {
// The search string we receive may contain escaped characters. For reducing
// the index we need individual, lower-cased words, ignoring escapings. For
@@ -192,6 +196,10 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
String16VectorFromString16(lower_unescaped_string, false, nullptr));
if (lower_words.empty())
continue;
+ // If we've already searched for this list of words, don't do it again.
+ if (search_string_words.find(lower_words) != search_string_words.end())
Peter Kasting 2017/05/05 23:07:34 Nit: Or base::ContainsKey(search_string_words, low
Mark P 2017/05/08 22:46:19 Left as-is. I find the current code a bit more re
+ continue;
+ search_string_words.insert(lower_words);
HistoryIDVector history_ids = HistoryIDsFromWords(lower_words);
history_ids_were_trimmed |= TrimHistoryIdsPool(&history_ids);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698