Commit c7188236 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

remove explicit transparent hasher from F14 usages with std::string key

Summary:
F14 tables with a std::string key now support heterogeneous
lookup by default (lookup and insert of StringPiece, std::string_view,
...).  This diff removes the explicit transparent hasher and equality
that used to be needed to get this behavior.

folly/experimental/StringKeyedUnorderedSet and Map will be removed later,
as they are unnecessary.

Reviewed By: ot, luciang

Differential Revision: D12905270

fbshipit-source-id: ecb990bb330866c089ba156f8be0a5b235c5574d
parent 9f56897b
...@@ -23,21 +23,15 @@ namespace folly { ...@@ -23,21 +23,15 @@ namespace folly {
template < template <
class Mapped, class Mapped,
class Hash = hasher<StringPiece>, class Hash = f14::DefaultHasher<std::string>,
class Eq = std::equal_to<StringPiece>, class Eq = f14::DefaultKeyEqual<std::string>,
class Alloc = f14::DefaultAlloc<std::pair<std::string const, Mapped>>> class Alloc = f14::DefaultAlloc<std::pair<std::string const, Mapped>>>
struct StringKeyedUnorderedMap : public F14NodeMap< struct StringKeyedUnorderedMap
std::string, : public F14NodeMap<std::string, Mapped, Hash, Eq, Alloc> {
Mapped, using Super = F14NodeMap<std::string, Mapped, Hash, Eq, Alloc>;
transparent<Hash>,
transparent<Eq>, using require_transparent_hash = typename Hash::is_transparent;
Alloc> { using require_transparent_eq = typename Eq::is_transparent;
using Super = F14NodeMap<
std::string,
Mapped,
transparent<Hash>,
transparent<Eq>,
Alloc>;
public: public:
using Super::Super; using Super::Super;
......
...@@ -16,17 +16,15 @@ ...@@ -16,17 +16,15 @@
#pragma once #pragma once
#include <folly/Range.h>
#include <folly/container/F14Set.h> #include <folly/container/F14Set.h>
namespace folly { namespace folly {
template < template <
class Hash = hasher<StringPiece>, class Hash = f14::DefaultHasher<std::string>,
class Eq = std::equal_to<StringPiece>, class Eq = f14::DefaultKeyEqual<std::string>,
class Alloc = f14::DefaultAlloc<std::string>> class Alloc = f14::DefaultAlloc<std::string>>
using BasicStringKeyedUnorderedSet = using BasicStringKeyedUnorderedSet = F14NodeSet<std::string, Hash, Eq, Alloc>;
F14NodeSet<std::string, transparent<Hash>, transparent<Eq>, Alloc>;
using StringKeyedUnorderedSet = BasicStringKeyedUnorderedSet<>; using StringKeyedUnorderedSet = BasicStringKeyedUnorderedSet<>;
......
...@@ -113,8 +113,8 @@ using ValueLeakChecker = ...@@ -113,8 +113,8 @@ using ValueLeakChecker =
using LeakCheckedUnorderedMap = StringKeyedUnorderedMap< using LeakCheckedUnorderedMap = StringKeyedUnorderedMap<
int, int,
folly::hasher<StringPiece>, folly::transparent<folly::hasher<StringPiece>>,
std::equal_to<StringPiece>, folly::transparent<std::equal_to<StringPiece>>,
MemoryLeakCheckerAllocator< MemoryLeakCheckerAllocator<
std::allocator<std::pair<const std::string, int>>>>; std::allocator<std::pair<const std::string, int>>>>;
...@@ -125,8 +125,8 @@ typedef StringKeyedMap<int, std::less<StringPiece>, KeyValuePairLeakChecker> ...@@ -125,8 +125,8 @@ typedef StringKeyedMap<int, std::less<StringPiece>, KeyValuePairLeakChecker>
LeakCheckedMap; LeakCheckedMap;
using LeakCheckedUnorderedSet = BasicStringKeyedUnorderedSet< using LeakCheckedUnorderedSet = BasicStringKeyedUnorderedSet<
folly::hasher<StringPiece>, folly::transparent<folly::hasher<StringPiece>>,
std::equal_to<folly::StringPiece>, folly::transparent<std::equal_to<folly::StringPiece>>,
MemoryLeakCheckerAllocator<std::allocator<std::string>>>; MemoryLeakCheckerAllocator<std::allocator<std::string>>>;
TEST(StringKeyedUnorderedMapTest, sanity) { TEST(StringKeyedUnorderedMapTest, sanity) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment