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

Unified Diff: components/query_parser/query_parser.cc

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter's comments Created 6 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
Index: components/query_parser/query_parser.cc
diff --git a/components/query_parser/query_parser.cc b/components/query_parser/query_parser.cc
index b9ac349ebded8e1b4c40250dde1c214cee0ee0da..42a9ad5de4d688b81c152ab67664559d23fc0790 100644
--- a/components/query_parser/query_parser.cc
+++ b/components/query_parser/query_parser.cc
@@ -46,16 +46,6 @@ void CoalesceMatchesFrom(size_t index, Snippet::MatchPositions* matches) {
}
}
-// Sorts the match positions in |matches| by their first index, then coalesces
-// any match positions that intersect each other.
-void CoalseAndSortMatchPositions(Snippet::MatchPositions* matches) {
- std::sort(matches->begin(), matches->end(), &CompareMatchPosition);
- // WARNING: we don't use iterator here as CoalesceMatchesFrom may remove
- // from matches.
- for (size_t i = 0; i < matches->size(); ++i)
- CoalesceMatchesFrom(i, matches);
-}
-
// Returns true if the character is considered a quote.
bool IsQueryQuote(wchar_t ch) {
return ch == '"' ||
@@ -392,7 +382,7 @@ bool QueryParser::DoesQueryMatch(const base::string16& text,
// completely punt here.
match_positions->clear();
} else {
- CoalseAndSortMatchPositions(&matches);
+ SortAndCoalesceMatchPositions(&matches);
match_positions->swap(matches);
}
return true;
@@ -468,9 +458,19 @@ void QueryParser::ExtractQueryWords(const base::string16& text,
words->push_back(QueryWord());
words->back().word = word;
words->back().position = iter.prev();
- }
+ }
}
}
}
+// static
+void QueryParser::SortAndCoalesceMatchPositions(
+ Snippet::MatchPositions* matches) {
+ std::sort(matches->begin(), matches->end(), &CompareMatchPosition);
+ // WARNING: we don't use iterator here as CoalesceMatchesFrom may remove
+ // from matches.
+ for (size_t i = 0; i < matches->size(); ++i)
+ CoalesceMatchesFrom(i, matches);
+}
+
} // namespace query_parser
« chrome/browser/bookmarks/bookmark_utils.cc ('K') | « components/query_parser/query_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698