Chromium Code Reviews| 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); |