Chromium Code Reviews| Index: base/version.cc |
| diff --git a/base/version.cc b/base/version.cc |
| index ede8a4586eb9bb8685b05a00939772cd7eaaefdb..4e71310aff5dba082d7937a725e8039738e63f80 100644 |
| --- a/base/version.cc |
| +++ b/base/version.cc |
| @@ -24,15 +24,17 @@ namespace { |
| // parsed successfully, false otherwise. |
| bool ParseVersionNumbers(const std::string& version_str, |
| std::vector<uint32_t>* parsed) { |
| - std::vector<std::string> numbers; |
| - SplitString(version_str, '.', &numbers); |
| + std::vector<StringPiece> numbers = |
| + SplitStringPiece(version_str, ".", KEEP_WHITESPACE, SPLIT_WANT_ALL); |
| if (numbers.empty()) |
| return false; |
| - for (std::vector<std::string>::const_iterator it = numbers.begin(); |
| - it != numbers.end(); ++it) { |
| - if (StartsWithASCII(*it, "+", false)) |
| + for (auto it = numbers.begin(); it != numbers.end(); ++it) { |
| + if (StartsWith(*it, "+", CompareCase::SENSITIVE)) |
| return false; |
| + |
| + // TODO(brettw) when we have a StringPiece version of StringToUint, delete |
| + // this string conversion. |
| unsigned int num; |
| if (!StringToUint(*it, &num)) |
| return false; |
| @@ -97,9 +99,11 @@ bool Version::IsValid() const { |
| // static |
| bool Version::IsValidWildcardString(const std::string& wildcard_string) { |
| - std::string version_string = wildcard_string; |
| - if (EndsWith(wildcard_string.c_str(), ".*", false)) |
| + std::string version_string; |
| + if (EndsWith(wildcard_string, ".*", CompareCase::SENSITIVE)) |
| version_string = wildcard_string.substr(0, wildcard_string.size() - 2); |
|
Peter Kasting
2015/06/15 20:41:40
Nit: Hmm... I think it might be more efficient to
brettw
2015/06/15 23:00:48
You're right. I'm going to do resize(version_strin
Peter Kasting
2015/06/16 00:08:18
OK... I actually find it a bit less clear semantic
|
| + else |
| + version_string = wildcard_string; |
| Version version(version_string); |
| return version.IsValid(); |
| @@ -117,7 +121,7 @@ int Version::CompareToWildcardString(const std::string& wildcard_string) const { |
| DCHECK(Version::IsValidWildcardString(wildcard_string)); |
| // Default behavior if the string doesn't end with a wildcard. |
| - if (!EndsWith(wildcard_string.c_str(), ".*", false)) { |
| + if (!EndsWith(wildcard_string, ".*", CompareCase::SENSITIVE)) { |
| Version version(wildcard_string); |
| DCHECK(version.IsValid()); |
| return CompareTo(version); |