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

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

Issue 2690303012: Cleaning up url_index_private_data and in_memory_url_index_types. (Closed)
Patch Set: Removing sorting, utilitiy for sets intersection. Created 3 years, 10 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
Index: components/omnibox/browser/url_index_private_data.h
diff --git a/components/omnibox/browser/url_index_private_data.h b/components/omnibox/browser/url_index_private_data.h
index 50bcf4b7ebc141548414f53a4b833f35de5717db..3b7afd8b2f5dddb1577ddaf1c2f900fbcf54a0b1 100644
--- a/components/omnibox/browser/url_index_private_data.h
+++ b/components/omnibox/browser/url_index_private_data.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <set>
+#include <stack>
#include <string>
#include "base/files/file_path.h"
@@ -204,9 +205,15 @@ class URLIndexPrivateData
// URL History indexing support functions.
- // Composes a set of history item IDs by intersecting the set for each word
+ // Composes a vector of history item IDs by intersecting the set for each word
// in |unsorted_words|.
- HistoryIDSet HistoryIDSetFromWords(const String16Vector& unsorted_words);
+ HistoryIDVector HistoryIDsFromWords(const String16Vector& unsorted_words);
+
+ // Trim the candidate pool if it is large. Note that we do not filter out
Peter Kasting 2017/02/18 01:46:31 Nit: Trims Might want to give a little idea of ho
dyaroshev 2017/02/18 11:48:14 Done.
+ // items that do not contain the search terms as proper substrings --
+ // doing so is the performance-costly operation we are trying to avoid in
+ // order to maintain omnibox responsiveness.
+ void TrimHistoryIdsPool(HistoryIDVector* history_ids) const;
// Helper function to HistoryIDSetFromWords which composes a set of history
// ids for the given term given in |term|.
@@ -216,13 +223,12 @@ class URLIndexPrivateData
WordIDSet WordIDSetForTermChars(const Char16Set& term_chars);
// Helper function for HistoryItemsForTerms(). Fills in |scored_items| from
- // the matches listed in |history_id_set|.
- void HistoryIdSetToScoredMatches(
- HistoryIDSet history_id_set,
- const base::string16& lower_raw_string,
- const TemplateURLService* template_url_service,
- bookmarks::BookmarkModel* bookmark_model,
- ScoredHistoryMatches* scored_items) const;
+ // the matches listed in |history_ids|.
+ void HistoryIdsToScoredMatches(HistoryIDVector history_ids,
+ const base::string16& lower_raw_string,
+ const TemplateURLService* template_url_service,
+ bookmarks::BookmarkModel* bookmark_model,
+ ScoredHistoryMatches* scored_items) const;
// Fills in |terms_to_word_starts_offsets| according to where the word starts
// in each term. For example, in the term "-foo" the word starts at offset 1.
@@ -253,17 +259,9 @@ class URLIndexPrivateData
// history item identified by |history_id| to the index.
void AddWordToIndex(const base::string16& uni_word, HistoryID history_id);
- // Creates a new entry in the word/history map for |word_id| and add
- // |history_id| as the initial element of the word's set.
- void AddWordHistory(const base::string16& uni_word, HistoryID history_id);
-
- // Updates an existing entry in the word/history index by adding the
- // |history_id| to set for |word_id| in the word_id_history_map_.
- void UpdateWordHistory(WordID word_id, HistoryID history_id);
-
- // Adds |word_id| to |history_id|'s entry in the history/word map,
- // creating a new entry if one does not already exist.
- void AddToHistoryIDWordMap(HistoryID history_id, WordID word_id);
+ // Adds a new entry to word_list. Uses previously freed positions if
+ // available.
+ WordID AddNewWordToWordList(const base::string16& term);
// Removes |row| and all associated words and characters from the index.
void RemoveRowFromIndex(const history::URLRow& row);
@@ -346,7 +344,7 @@ class URLIndexPrivateData
// modified or deleted old words may be removed from the index, in which
// case the slots for those words are added to available_words_ for resuse
// by future URL updates.
- WordIDSet available_words_;
+ std::stack<WordID> available_words_;
// A one-to-one mapping from the a word string to its slot number (i.e.
// WordID) in the |word_list_|.

Powered by Google App Engine
This is Rietveld 408576698