This change plumbs an equality function object type through the quiche linked hash map type. This will enable future changes to the hashing behavior of SpdyHeaderBlock. gfe-relnote: Adds a class template parameter with an appropriate default. No functional change intended. PiperOrigin-RevId: 287990478 Change-Id: Icd72f36561fc31f2f7092306b960e4d8721aa774
diff --git a/common/platform/api/quiche_unordered_containers.h b/common/platform/api/quiche_unordered_containers.h index 583f97e..a53a206 100644 --- a/common/platform/api/quiche_unordered_containers.h +++ b/common/platform/api/quiche_unordered_containers.h
@@ -5,6 +5,8 @@ #ifndef QUICHE_COMMON_PLATFORM_API_QUICHE_UNORDERED_CONTAINERS_H_ #define QUICHE_COMMON_PLATFORM_API_QUICHE_UNORDERED_CONTAINERS_H_ +#include <functional> + #include "net/quiche/common/platform/impl/quiche_unordered_containers_impl.h" namespace quiche { @@ -16,8 +18,9 @@ // A general-purpose unordered map. template <typename Key, typename Value, - typename Hash = QuicheDefaultHasher<Key>> -using QuicheUnorderedMap = QuicheUnorderedMapImpl<Key, Value, Hash>; + typename Hash = QuicheDefaultHasher<Key>, + typename Eq = std::equal_to<Key>> +using QuicheUnorderedMap = QuicheUnorderedMapImpl<Key, Value, Hash, Eq>; } // namespace quiche
diff --git a/common/simple_linked_hash_map.h b/common/simple_linked_hash_map.h index b7488eb..6eb6ed9 100644 --- a/common/simple_linked_hash_map.h +++ b/common/simple_linked_hash_map.h
@@ -16,6 +16,7 @@ #ifndef QUICHE_COMMON_SIMPLE_LINKED_HASH_MAP_H_ #define QUICHE_COMMON_SIMPLE_LINKED_HASH_MAP_H_ +#include <functional> #include <list> #include <tuple> #include <type_traits> @@ -33,11 +34,15 @@ // We also keep a set<list::iterator> for find. Since std::list is a // doubly-linked list, the iterators should remain stable. -template <class Key, class Value, class Hash = std::hash<Key>> +template <class Key, + class Value, + class Hash = std::hash<Key>, + class Eq = std::equal_to<Key>> class SimpleLinkedHashMap { private: typedef std::list<std::pair<Key, Value>> ListType; - typedef QuicheUnorderedMap<Key, typename ListType::iterator, Hash> MapType; + typedef QuicheUnorderedMap<Key, typename ListType::iterator, Hash, Eq> + MapType; public: typedef typename ListType::iterator iterator;
diff --git a/spdy/core/spdy_header_block.h b/spdy/core/spdy_header_block.h index b02284f..56ee1d5 100644 --- a/spdy/core/spdy_header_block.h +++ b/spdy/core/spdy_header_block.h
@@ -7,6 +7,7 @@ #include <stddef.h> +#include <functional> #include <list> #include <string> #include <utility> @@ -81,7 +82,10 @@ size_t separator_size_ = 0; }; - typedef SpdyLinkedHashMap<SpdyStringPiece, HeaderValue, SpdyStringPieceHash> + typedef SpdyLinkedHashMap<SpdyStringPiece, + HeaderValue, + SpdyStringPieceHash, + std::equal_to<SpdyStringPiece>> MapType; public:
diff --git a/spdy/platform/api/spdy_containers.h b/spdy/platform/api/spdy_containers.h index 9a90556..1449c3c 100644 --- a/spdy/platform/api/spdy_containers.h +++ b/spdy/platform/api/spdy_containers.h
@@ -24,8 +24,8 @@ using SpdyHashSet = SpdyHashSetImpl<ElementType, Hasher, Eq>; // A map which offers insertion-ordered iteration. -template <typename Key, typename Value, typename Hash = SpdyHash<Key>> -using SpdyLinkedHashMap = SpdyLinkedHashMapImpl<Key, Value, Hash>; +template <typename Key, typename Value, typename Hash, typename Eq> +using SpdyLinkedHashMap = SpdyLinkedHashMapImpl<Key, Value, Hash, Eq>; // A vector optimized for small sizes. Provides the same APIs as a std::vector. template <typename T, size_t N, typename A = std::allocator<T>>