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

Unified Diff: chrome/browser/history/query_parser.cc

Issue 10913262: Implement Bookmark Autocomplete Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixed match position coalescing. Created 8 years, 2 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: chrome/browser/history/query_parser.cc
===================================================================
--- chrome/browser/history/query_parser.cc (revision 159706)
+++ chrome/browser/history/query_parser.cc (working copy)
@@ -22,7 +22,7 @@
}
// Returns true if |mp2| intersects |mp1|. This is intended for use by
-// CoalesceMatchesFrom and isn't meant as a general intersectpion comparison
+// CoalesceMatchesFrom and isn't meant as a general intersection comparison
// function.
bool SnippetIntersects(const Snippet::MatchPosition& mp1,
const Snippet::MatchPosition& mp2) {
@@ -36,7 +36,8 @@
for (Snippet::MatchPositions::iterator i = matches->begin() + index + 1;
i != matches->end(); ) {
if (SnippetIntersects(mp, *i)) {
- mp.second = i->second;
+ mp.first = std::min(mp.first, i->first);
sky 2012/10/15 23:32:34 I get the need for std::max on 40, bug 39 shouldn'
mrossetti 2012/10/16 16:38:05 Makes sense. Thanks.
+ mp.second = std::max(mp.second, i->second);
i = matches->erase(i);
} else {
return;
@@ -125,16 +126,17 @@
bool QueryNodeWord::HasMatchIn(const std::vector<QueryWord>& words,
Snippet::MatchPositions* match_positions) const {
+ bool matched = false;
for (size_t i = 0; i < words.size(); ++i) {
if (Matches(words[i].word, false)) {
size_t match_start = words[i].position;
match_positions->push_back(
Snippet::MatchPosition(match_start,
match_start + static_cast<int>(word_.size())));
- return true;
+ matched = true;
}
}
- return false;
+ return matched;
}
void QueryNodeWord::AppendWords(std::vector<string16>* words) const {

Powered by Google App Engine
This is Rietveld 408576698