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

Side by Side Diff: net/tools/balsa/string_piece_utils.h

Issue 1224553010: Replace base::str[n]casecmp with helper functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « net/tools/balsa/balsa_headers.h ('k') | net/tools/quic/test_tools/http_message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_ 5 #ifndef NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_
6 #define NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_ 6 #define NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_
7 7
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 size_t hash_val = 0; 58 size_t hash_val = 0;
59 for (base::StringPiece::const_iterator it = sp.begin(); 59 for (base::StringPiece::const_iterator it = sp.begin();
60 it != sp.end(); ++it) { 60 it != sp.end(); ++it) {
61 hash_val = 5 * hash_val + base::ToLowerASCII(*it); 61 hash_val = 5 * hash_val + base::ToLowerASCII(*it);
62 } 62 }
63 return hash_val; 63 return hash_val;
64 } 64 }
65 }; 65 };
66 #endif // COMPILER_MSVC 66 #endif // COMPILER_MSVC
67 67
68 struct StringPieceUtils {
69 // ASCII case-insensitive equality.
70 static bool EqualIgnoreCase(const base::StringPiece& piece1,
71 const base::StringPiece& piece2) {
72 base::StringPiece::const_iterator p1i = piece1.begin();
73 base::StringPiece::const_iterator p2i = piece2.begin();
74 if (piece1.empty() && piece2.empty()) {
75 return true;
76 } else if (piece1.size() != piece2.size()) {
77 return false;
78 }
79 while (p1i != piece1.end() && p2i != piece2.end()) {
80 if (base::ToLowerASCII(*p1i) != base::ToLowerASCII(*p2i))
81 return false;
82 ++p1i;
83 ++p2i;
84 }
85 return true;
86 }
87 };
88
89 struct StringPieceCaseEqual { 68 struct StringPieceCaseEqual {
90 bool operator()(const base::StringPiece& piece1, 69 bool operator()(const base::StringPiece& piece1,
91 const base::StringPiece& piece2) const { 70 const base::StringPiece& piece2) const {
92 return StringPieceUtils::EqualIgnoreCase(piece1, piece2); 71 return base::EqualsCaseInsensitiveASCII(piece1, piece2);
93 } 72 }
94 }; 73 };
95 74
96 } // namespace net 75 } // namespace net
97 76
98 #endif // NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_ 77 #endif // NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_
99 78
OLDNEW
« no previous file with comments | « net/tools/balsa/balsa_headers.h ('k') | net/tools/quic/test_tools/http_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698