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

Unified Diff: url/url_util.cc

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 years, 6 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 | « url/url_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_util.cc
diff --git a/url/url_util.cc b/url/url_util.cc
index 008a5e48b687dddb0d14f62743ba201763f3d97d..28a8931941c44422335c9f0ad1b9623d53dd51fb 100644
--- a/url/url_util.cc
+++ b/url/url_util.cc
@@ -9,6 +9,7 @@
#include "base/debug/leak_annotations.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "url/url_canon_internal.h"
#include "url/url_file.h"
#include "url/url_util_internal.h"
@@ -17,23 +18,6 @@ namespace url {
namespace {
-// ASCII-specific tolower. The standard library's tolower is locale sensitive,
-// so we don't want to use it here.
-template<class Char>
-inline Char ToLowerASCII(Char c) {
- return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
-}
-
-// Backend for LowerCaseEqualsASCII.
-template<typename Iter>
-inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char* b) {
- for (Iter it = a_begin; it != a_end; ++it, ++b) {
- if (!*b || ToLowerASCII(*it) != *b)
- return false;
- }
- return *b == 0;
-}
-
const int kNumStandardURLSchemes = 8;
const char* kStandardURLSchemes[kNumStandardURLSchemes] = {
kHttpScheme,
@@ -72,9 +56,9 @@ inline bool DoCompareSchemeComponent(const CHAR* spec,
const char* compare_to) {
if (!component.is_nonempty())
return compare_to[0] == 0; // When component is empty, match empty scheme.
- return LowerCaseEqualsASCII(&spec[component.begin],
- &spec[component.end()],
- compare_to);
+ return base::LowerCaseEqualsASCII(&spec[component.begin],
+ &spec[component.end()],
+ compare_to);
}
// Returns true if the given scheme identified by |scheme| within |spec| is one
@@ -86,8 +70,8 @@ bool DoIsStandard(const CHAR* spec, const Component& scheme) {
InitStandardSchemes();
for (size_t i = 0; i < standard_schemes->size(); i++) {
- if (LowerCaseEqualsASCII(&spec[scheme.begin], &spec[scheme.end()],
- standard_schemes->at(i)))
+ if (base::LowerCaseEqualsASCII(&spec[scheme.begin], &spec[scheme.end()],
+ standard_schemes->at(i)))
return true;
}
return false;
@@ -486,31 +470,6 @@ bool ReplaceComponents(const char* spec,
charset_converter, output, out_parsed);
}
-// Front-ends for LowerCaseEqualsASCII.
-bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
-}
-
-bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b_begin,
- const char* b_end) {
- while (a_begin != a_end && b_begin != b_end &&
- ToLowerASCII(*a_begin) == *b_begin) {
- a_begin++;
- b_begin++;
- }
- return a_begin == a_end && b_begin == b_end;
-}
-
-bool LowerCaseEqualsASCII(const base::char16* a_begin,
- const base::char16* a_end,
- const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
-}
-
void DecodeURLEscapeSequences(const char* input,
int length,
CanonOutputW* output) {
« no previous file with comments | « url/url_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698