Update SplitString calls in components
This converts calls from the old form to the new form. Some calls that iterated over the results were changed to a range-based for loop with an inline call to SplitString. Some places were changed to use StringPieces when it was safe to do so.
Review URL: https://codereview.chromium.org/1234973004
Cr-Commit-Position: refs/heads/master@{#340209}
diff --git a/components/variations/net/variations_http_header_provider.cc b/components/variations/net/variations_http_header_provider.cc
index f94ad2c..ff8fd201 100644
--- a/components/variations/net/variations_http_header_provider.cc
+++ b/components/variations/net/variations_http_header_provider.cc
@@ -88,21 +88,20 @@
const std::string& variation_ids) {
default_variation_ids_set_.clear();
default_trigger_id_set_.clear();
- std::vector<std::string> entries;
- base::SplitString(variation_ids, ',', &entries);
- for (std::vector<std::string>::const_iterator it = entries.begin();
- it != entries.end(); ++it) {
- if (it->empty()) {
+ for (const base::StringPiece& entry : base::SplitStringPiece(
+ variation_ids, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (entry.empty()) {
default_variation_ids_set_.clear();
default_trigger_id_set_.clear();
return false;
}
- bool trigger_id = base::StartsWith(*it, "t", base::CompareCase::SENSITIVE);
+ bool trigger_id =
+ base::StartsWith(entry, "t", base::CompareCase::SENSITIVE);
// Remove the "t" prefix if it's there.
- std::string entry = trigger_id ? it->substr(1) : *it;
+ base::StringPiece trimmed_entry = trigger_id ? entry.substr(1) : entry;
int variation_id = 0;
- if (!base::StringToInt(entry, &variation_id)) {
+ if (!base::StringToInt(trimmed_entry, &variation_id)) {
default_variation_ids_set_.clear();
default_trigger_id_set_.clear();
return false;