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

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

Issue 2862813002: Insertion by one sometimes gives drammatically better results than (Closed)
Patch Set: Created 3 years, 7 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 | « base/containers/flat_tree.h ('k') | 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..2671573ba1e12cba45be7267fd7f4a6bdfeed7a7 100644
--- a/components/omnibox/browser/url_index_private_data.cc
+++ b/components/omnibox/browser/url_index_private_data.cc
@@ -590,6 +590,15 @@ HistoryIDSet URLIndexPrivateData::HistoryIDsForTerm(
// the sets from each word.
// We use |buffer| because it's more efficient to collect everything and then
// construct a flat_set than to insert elements one by one.
+
+#define BUFFER 1
+#define BY_ONE 2
+#define MERGE 3
+
+#define METHOD MERGE
+
+#if METHOD == BUFFER
+
HistoryIDVector buffer;
for (WordID word_id : word_id_set) {
WordIDHistoryMap::iterator word_iter = word_id_history_map_.find(word_id);
@@ -602,6 +611,34 @@ HistoryIDSet URLIndexPrivateData::HistoryIDsForTerm(
HistoryIDSet history_id_set(buffer.begin(), buffer.end(),
base::KEEP_FIRST_OF_DUPES);
+#elif METHOD == BY_ONE
+
+ HistoryIDSet history_id_set;
+
+ for (WordID word_id : word_id_set) {
+ WordIDHistoryMap::iterator word_iter = word_id_history_map_.find(word_id);
+ if (word_iter != word_id_history_map_.end()) {
+ HistoryIDSet& word_history_id_set(word_iter->second);
+ history_id_set.insert_by_one(word_history_id_set.begin(),
+ word_history_id_set.end());
+ }
+ }
+
+#else // MERGE
+
+ HistoryIDSet history_id_set;
+
+ for (WordID word_id : word_id_set) {
+ WordIDHistoryMap::iterator word_iter = word_id_history_map_.find(word_id);
+ if (word_iter != word_id_history_map_.end()) {
+ HistoryIDSet& word_history_id_set(word_iter->second);
+ history_id_set.insert_merge(word_history_id_set.begin(),
+ word_history_id_set.end());
+ }
+ }
+
+#endif
+
// Record a new cache entry for this word if the term is longer than
// a single character.
if (term_length > 1)
« no previous file with comments | « base/containers/flat_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698