| Index: base/strings/string_piece.h
|
| diff --git a/base/strings/string_piece.h b/base/strings/string_piece.h
|
| index 92634b9362b7dfb405ef7c7210f90688e385d25d..2efc3e95eb3655160c8e5d84d6e52398e66d994c 100644
|
| --- a/base/strings/string_piece.h
|
| +++ b/base/strings/string_piece.h
|
| @@ -28,7 +28,6 @@
|
| #include <string>
|
|
|
| #include "base/base_export.h"
|
| -#include "base/containers/hash_tables.h"
|
| #include "base/logging.h"
|
| #include "base/strings/string16.h"
|
|
|
| @@ -432,8 +431,6 @@ inline bool operator>=(const StringPiece16& x, const StringPiece16& y) {
|
| BASE_EXPORT std::ostream& operator<<(std::ostream& o,
|
| const StringPiece& piece);
|
|
|
| -} // namespace base
|
| -
|
| // Hashing ---------------------------------------------------------------------
|
|
|
| // We provide appropriate hash functions so StringPiece and StringPiece16 can
|
| @@ -442,28 +439,24 @@ BASE_EXPORT std::ostream& operator<<(std::ostream& o,
|
| // This hash function is copied from base/strings/string16.h. We don't use the
|
| // ones already defined for string and string16 directly because it would
|
| // require the string constructors to be called, which we don't want.
|
| -#define HASH_STRING_PIECE(StringPieceType, string_piece) \
|
| - std::size_t result = 0; \
|
| - for (StringPieceType::const_iterator i = string_piece.begin(); \
|
| - i != string_piece.end(); ++i) \
|
| - result = (result * 131) + *i; \
|
| - return result; \
|
| -
|
| -namespace BASE_HASH_NAMESPACE {
|
| -
|
| -template<>
|
| -struct hash<base::StringPiece> {
|
| - std::size_t operator()(const base::StringPiece& sp) const {
|
| - HASH_STRING_PIECE(base::StringPiece, sp);
|
| +#define HASH_STRING_PIECE(StringPieceType, string_piece) \
|
| + std::size_t result = 0; \
|
| + for (StringPieceType::const_iterator i = string_piece.begin(); \
|
| + i != string_piece.end(); ++i) \
|
| + result = (result * 131) + *i; \
|
| + return result;
|
| +
|
| +struct StringPieceHash {
|
| + std::size_t operator()(const StringPiece& sp) const {
|
| + HASH_STRING_PIECE(StringPiece, sp);
|
| }
|
| };
|
| -template<>
|
| -struct hash<base::StringPiece16> {
|
| - std::size_t operator()(const base::StringPiece16& sp16) const {
|
| - HASH_STRING_PIECE(base::StringPiece16, sp16);
|
| +struct StringPiece16Hash {
|
| + std::size_t operator()(const StringPiece16& sp16) const {
|
| + HASH_STRING_PIECE(StringPiece16, sp16);
|
| }
|
| };
|
|
|
| -} // namespace BASE_HASH_NAMESPACE
|
| +} // namespace base
|
|
|
| #endif // BASE_STRINGS_STRING_PIECE_H_
|
|
|