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

Unified Diff: base/strings/string_util.cc

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | « base/strings/string_util.h ('k') | chrome/browser/auto_launch_trial.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_util.cc
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index ab9570f6741a5f8d981dbfd278fa37512320da50..8d2bbc55791a1958c5c16c89f7b9fbb308a8247b 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -354,38 +354,38 @@ bool IsStringUTF8(const std::string& str) {
return true;
}
-} // namespace base
-
-template<typename Iter>
-static inline bool DoLowerCaseEqualsASCII(Iter a_begin,
- Iter a_end,
- const char* b) {
- for (Iter it = a_begin; it != a_end; ++it, ++b) {
- if (!*b || base::ToLowerASCII(*it) != *b)
+template<typename StringType>
+static inline bool DoLowerCaseEqualsASCII(BasicStringPiece<StringType> str,
+ const char* lower_cased_cmp) {
+ for (typename BasicStringPiece<StringType>::const_iterator it = str.begin();
+ it != str.end(); ++it, ++lower_cased_cmp) {
+ if (!*lower_cased_cmp || base::ToLowerASCII(*it) != *lower_cased_cmp)
return false;
}
- return *b == 0;
+ return *lower_cased_cmp == 0;
}
// Front-ends for LowerCaseEqualsASCII.
-bool LowerCaseEqualsASCII(const std::string& a, const char* b) {
- return DoLowerCaseEqualsASCII(a.begin(), a.end(), b);
+bool LowerCaseEqualsASCII(StringPiece str, const char* lower_cased_cmp) {
+ return DoLowerCaseEqualsASCII(str, lower_cased_cmp);
}
-bool LowerCaseEqualsASCII(const string16& a, const char* b) {
- return DoLowerCaseEqualsASCII(a.begin(), a.end(), b);
+bool LowerCaseEqualsASCII(StringPiece16 str, const char* lower_cased_cmp) {
+ return DoLowerCaseEqualsASCII(str, lower_cased_cmp);
}
bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
std::string::const_iterator a_end,
const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
+ const char* a = &*a_begin;
+ return LowerCaseEqualsASCII(StringPiece(a, a_end - a_begin), b);
}
bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
string16::const_iterator a_end,
const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
+ const char16* a = &*a_begin;
+ return LowerCaseEqualsASCII(StringPiece16(a, a_end - a_begin), b);
}
// TODO(port): Resolve wchar_t/iterator issues that require OS_ANDROID here.
@@ -393,17 +393,18 @@ bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
bool LowerCaseEqualsASCII(const char* a_begin,
const char* a_end,
const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
+ return DoLowerCaseEqualsASCII(StringPiece(a_begin, a_end - a_begin), b);
}
bool LowerCaseEqualsASCII(const char16* a_begin,
const char16* a_end,
const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
+ return DoLowerCaseEqualsASCII(StringPiece16(a_begin, a_end - a_begin), b);
}
-
#endif // !defined(OS_ANDROID)
+} // namespace base
+
bool EqualsASCII(const string16& a, const base::StringPiece& b) {
if (a.length() != b.length())
return false;
« no previous file with comments | « base/strings/string_util.h ('k') | chrome/browser/auto_launch_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698