diff options
author | brettw <brettw@chromium.org> | 2015-08-06 17:11:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 00:12:13 +0000 |
commit | 0aa7c64253cca8b636d52d1d01d94f96ab9c13fa (patch) | |
tree | 29b825a84dffc4d7310c69b22da0cfd7b1228277 /gpu | |
parent | 924597ba8b5def174aebdc96368545f51df1bee2 (diff) | |
download | chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.zip chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.tar.gz chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.tar.bz2 |
Update SplitString calls to new form
Uses the new form for most (but not quite all) of the remaining users of the old form.
Changes media mime util codec list parsing to expect no result from the string "," rather than two empty strings. The old SplitString call had a special case where if the input was empty, it would return empty, but if it had one split character, it would return two empty strings as results.
The new one lets you choose but the options are either (1) empty string -> one empty string and "," -> two empty strings, or (2) map both to no results for when you don't want empty results. I'm pretty sure media codec parsing actually wants the latter behavior, so I updated the call to discard empty results and MimeUtilTest.ParseCodecString is updated.
Review URL: https://codereview.chromium.org/1272823003
Cr-Commit-Position: refs/heads/master@{#342238}
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 8 | ||||
-rw-r--r-- | gpu/config/gpu_control_list.cc | 8 | ||||
-rw-r--r-- | gpu/config/gpu_info_collector.cc | 4 | ||||
-rw-r--r-- | gpu/config/gpu_info_collector_android.cc | 4 | ||||
-rw-r--r-- | gpu/config/gpu_info_collector_linux.cc | 5 | ||||
-rw-r--r-- | gpu/config/gpu_test_expectations_parser.cc | 14 | ||||
-rw-r--r-- | gpu/config/gpu_util.cc | 8 |
7 files changed, 28 insertions, 23 deletions
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index 6f6cf63..b8737fc 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -83,11 +83,11 @@ class StringSet { void StringToWorkarounds( const std::string& types, FeatureInfo::Workarounds* workarounds) { DCHECK(workarounds); - std::vector<std::string> pieces; - base::SplitString(types, ',', &pieces); - for (size_t i = 0; i < pieces.size(); ++i) { + for (const base::StringPiece& piece : + base::SplitStringPiece( + types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { int number = 0; - bool succeed = base::StringToInt(pieces[i], &number); + bool succeed = base::StringToInt(piece, &number); DCHECK(succeed); switch (number) { #define GPU_OP(type, name) \ diff --git a/gpu/config/gpu_control_list.cc b/gpu/config/gpu_control_list.cc index 1fbf0b6..2e44e3d 100644 --- a/gpu/config/gpu_control_list.cc +++ b/gpu/config/gpu_control_list.cc @@ -25,7 +25,9 @@ bool ProcessVersionString(const std::string& version_string, char splitter, std::vector<std::string>* version) { DCHECK(version); - base::SplitString(version_string, splitter, version); + *version = base::SplitString( + version_string, std::string(1, splitter), + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (version->size() == 0) return false; // If the splitter is '-', we assume it's a date with format "mm-dd-yyyy"; @@ -1028,8 +1030,8 @@ bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) return false; - std::vector<std::string> segments; - base::SplitString(gl_version, ' ', &segments); + std::vector<std::string> segments = base::SplitString( + gl_version, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); std::string number; GLType gl_type = kGLTypeNone; if (segments.size() > 2 && diff --git a/gpu/config/gpu_info_collector.cc b/gpu/config/gpu_info_collector.cc index 55a2947..23da95e 100644 --- a/gpu/config/gpu_info_collector.cc +++ b/gpu/config/gpu_info_collector.cc @@ -68,8 +68,8 @@ std::string GetVersionFromString(const std::string& version_string) { sub_string = version_string.substr(begin, end - begin); else sub_string = version_string.substr(begin); - std::vector<std::string> pieces; - base::SplitString(sub_string, '.', &pieces); + std::vector<std::string> pieces = base::SplitString( + sub_string, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (pieces.size() >= 2) return pieces[0] + "." + pieces[1]; } diff --git a/gpu/config/gpu_info_collector_android.cc b/gpu/config/gpu_info_collector_android.cc index 93da6a9..c6d9b19 100644 --- a/gpu/config/gpu_info_collector_android.cc +++ b/gpu/config/gpu_info_collector_android.cc @@ -34,8 +34,8 @@ std::pair<std::string, size_t> GetVersionFromString( sub_string = version_string.substr(begin, end - begin); else sub_string = version_string.substr(begin); - std::vector<std::string> pieces; - base::SplitString(sub_string, '.', &pieces); + std::vector<std::string> pieces = base::SplitString( + sub_string, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (pieces.size() >= 2) return std::make_pair(pieces[0] + "." + pieces[1], end); else diff --git a/gpu/config/gpu_info_collector_linux.cc b/gpu/config/gpu_info_collector_linux.cc index 976aff6..e93a79c 100644 --- a/gpu/config/gpu_info_collector_linux.cc +++ b/gpu/config/gpu_info_collector_linux.cc @@ -247,8 +247,9 @@ CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { std::string gl_version = gpu_info->gl_version; if (base::StartsWith(gl_version, "OpenGL ES", base::CompareCase::SENSITIVE)) gl_version = gl_version.substr(10); - std::vector<std::string> pieces; - base::SplitStringAlongWhitespace(gl_version, &pieces); + std::vector<std::string> pieces = base::SplitString( + gl_version, base::kWhitespaceASCII, base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); // In linux, the gl version string might be in the format of // GLVersion DriverVendor DriverVersion if (pieces.size() < 3) diff --git a/gpu/config/gpu_test_expectations_parser.cc b/gpu/config/gpu_test_expectations_parser.cc index d44e5bb..27a1487 100644 --- a/gpu/config/gpu_test_expectations_parser.cc +++ b/gpu/config/gpu_test_expectations_parser.cc @@ -187,8 +187,8 @@ bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { entries_.clear(); error_messages_.clear(); - std::vector<std::string> lines; - base::SplitString(data, '\n', &lines); + std::vector<std::string> lines = base::SplitString( + data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); bool rt = true; for (size_t i = 0; i < lines.size(); ++i) { if (!ParseLine(lines[i], i + 1)) @@ -234,8 +234,9 @@ GPUTestExpectationsParser::GetErrorMessages() const { bool GPUTestExpectationsParser::ParseConfig( const std::string& config_data, GPUTestConfig* config) { DCHECK(config); - std::vector<std::string> tokens; - base::SplitStringAlongWhitespace(config_data, &tokens); + std::vector<std::string> tokens = base::SplitString( + config_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); for (size_t i = 0; i < tokens.size(); ++i) { Token token = ParseToken(tokens[i]); @@ -284,8 +285,9 @@ bool GPUTestExpectationsParser::ParseConfig( bool GPUTestExpectationsParser::ParseLine( const std::string& line_data, size_t line_number) { - std::vector<std::string> tokens; - base::SplitStringAlongWhitespace(line_data, &tokens); + std::vector<std::string> tokens = base::SplitString( + line_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); int32 stage = kLineParserBegin; GPUTestExpectationEntry entry; entry.line_number = line_number; diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc index 5d67988..80a99fb 100644 --- a/gpu/config/gpu_util.cc +++ b/gpu/config/gpu_util.cc @@ -34,11 +34,11 @@ std::string IntSetToString(const std::set<int>& list) { void StringToIntSet(const std::string& str, std::set<int>* list) { DCHECK(list); - std::vector<std::string> pieces; - base::SplitString(str, ',', &pieces); - for (size_t i = 0; i < pieces.size(); ++i) { + for (const base::StringPiece& piece : + base::SplitStringPiece(str, ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL)) { int number = 0; - bool succeed = base::StringToInt(pieces[i], &number); + bool succeed = base::StringToInt(piece, &number); DCHECK(succeed); list->insert(number); } |