Chromium Code Reviews| Index: net/quic/string_piece_utils.h |
| diff --git a/net/tools/balsa/string_piece_utils.h b/net/quic/string_piece_utils.h |
| similarity index 36% |
| copy from net/tools/balsa/string_piece_utils.h |
| copy to net/quic/string_piece_utils.h |
| index 12fc69be85fca9e2ccda824d50774bada11dc587..c073256bae5db8d530c9b5a147606ba92ebbc63b 100644 |
| --- a/net/tools/balsa/string_piece_utils.h |
| +++ b/net/quic/string_piece_utils.h |
| @@ -2,57 +2,15 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_ |
| -#define NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_ |
| +#ifndef NET_QUIC_STRING_PIECE_UTILS_H_ |
| +#define NET_QUIC_STRING_PIECE_UTILS_H_ |
| #include <ctype.h> |
| -#include "base/port.h" |
| #include "base/strings/string_piece.h" |
| namespace net { |
| -#if defined(COMPILER_MSVC) |
| -struct StringPieceCaseCompare { |
| - static const size_t bucket_size = 4; |
| - |
| - size_t operator()(const base::StringPiece& sp) const { |
| - // based on __stl_string_hash in http://www.sgi.com/tech/stl/string |
| - size_t hash_val = 0; |
| - for (base::StringPiece::const_iterator it = sp.begin(); |
| - it != sp.end(); ++it) { |
| - hash_val = 5 * hash_val + tolower(*it); |
| - } |
| - return hash_val; |
| - } |
| - |
| - bool operator()(const base::StringPiece& sp1, |
| - const base::StringPiece& sp2) const { |
| - size_t len1 = sp1.length(); |
| - size_t len2 = sp2.length(); |
| - bool sp1_shorter = len1 < len2; |
| - size_t len = sp1_shorter ? len1 : len2; |
| - int rv = _memicmp(sp1.data(), sp2.data(), len); |
| - if (rv == 0) { |
| - return sp1_shorter; |
| - } |
| - return rv < 0; |
| - } |
| -}; |
| -#else // COMPILER_MSVC |
| -struct StringPieceCaseHash { |
| - size_t operator()(const base::StringPiece& sp) const { |
| - // based on __stl_string_hash in http://www.sgi.com/tech/stl/string |
| - size_t hash_val = 0; |
| - for (base::StringPiece::const_iterator it = sp.begin(); |
| - it != sp.end(); ++it) { |
| - hash_val = 5 * hash_val + tolower(*it); |
| - } |
| - return hash_val; |
| - } |
| -}; |
| -#endif // COMPILER_MSVC |
| - |
| struct StringPieceUtils { |
| static bool EqualIgnoreCase(const base::StringPiece& piece1, |
| const base::StringPiece& piece2) { |
| @@ -72,24 +30,6 @@ struct StringPieceUtils { |
| return true; |
| } |
| - static void RemoveWhitespaceContext(base::StringPiece* piece1) { |
| - base::StringPiece::const_iterator c = piece1->begin(); |
| - base::StringPiece::const_iterator e = piece1->end(); |
| - while (c != e && isspace(*c)) { |
| - ++c; |
| - } |
| - if (c == e) { |
| - *piece1 = base::StringPiece(c, e-c); |
| - return; |
| - } |
| - --e; |
| - while (c != e &&isspace(*e)) { |
| - --e; |
| - } |
| - ++e; |
| - *piece1 = base::StringPiece(c, e-c); |
| - } |
| - |
| static bool StartsWithIgnoreCase(const base::StringPiece& text, |
|
wtc
2014/06/25 22:22:25
IMPORTANT: It seems that the only thing we need fr
dmziegler
2014/06/26 01:23:29
Done.
|
| const base::StringPiece& starts_with) { |
| if (text.size() < starts_with.size()) |
| @@ -97,16 +37,7 @@ struct StringPieceUtils { |
| return EqualIgnoreCase(text.substr(0, starts_with.size()), starts_with); |
| } |
| }; |
| -struct StringPieceCaseEqual { |
| - bool operator()(const base::StringPiece& piece1, |
| - const base::StringPiece& piece2) const { |
| - return StringPieceUtils::EqualIgnoreCase(piece1, piece2); |
| - } |
| -}; |
| - |
| - |
| - |
| } // namespace net |
|
wtc
2014/06/25 22:22:24
Add a blank line before this line.
|
| -#endif // NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_ |
| +#endif // NET_QUIC_STRING_PIECE_UTILS_H_ |