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

Unified Diff: components/query_parser/snippet_unittest.cc

Issue 1234973004: Update SplitString calls in components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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/snippet_unittest.cc
diff --git a/components/query_parser/snippet_unittest.cc b/components/query_parser/snippet_unittest.cc
index 7f96f67b6c2791053df42b66fb3723a7798cff6f..12086ee9e793abc4168646373fd64dc4e2dfd3a1 100644
--- a/components/query_parser/snippet_unittest.cc
+++ b/components/query_parser/snippet_unittest.cc
@@ -96,22 +96,18 @@ base::string16 BuildSnippet(const std::string& document,
// |document|. We need to add more test cases and change this function
// to be more generic depending on how we deal with 'folding for match'
// in history.
- const std::string document_folded =
- base::StringToLowerASCII(std::string(document));
-
- std::vector<std::string> query_words;
- base::SplitString(query, ' ', &query_words);
+ const std::string document_folded = base::StringToLowerASCII(document);
// Manually construct match_positions of the document.
Snippet::MatchPositions match_positions;
match_positions.clear();
- for (std::vector<std::string>::iterator qw = query_words.begin();
- qw != query_words.end(); ++qw) {
+ for (const std::string& word : base::SplitString(
+ query, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) {
// Insert all instances of this word into match_pairs.
size_t ofs = 0;
- while ((ofs = document_folded.find(*qw, ofs)) != std::string::npos) {
- match_positions.push_back(std::make_pair(ofs, ofs + qw->size()));
- ofs += qw->size();
+ while ((ofs = document_folded.find(word, ofs)) != std::string::npos) {
+ match_positions.push_back(std::make_pair(ofs, ofs + word.size()));
+ ofs += word.size();
}
}
// Sort match_positions in order of increasing offset.

Powered by Google App Engine
This is Rietveld 408576698