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

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: fixes 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
« no previous file with comments | « components/query_parser/snippet.cc ('k') | components/search_engines/default_search_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c560d58e9330833692db5f5baa378f9be4c6f04b 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::TRIM_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.
« no previous file with comments | « components/query_parser/snippet.cc ('k') | components/search_engines/default_search_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698