From a43062c575c1f809ba65134b6b856f06b14930b6 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Fri, 11 Nov 2022 21:23:47 +0100
Subject: [PATCH] RemoteTagCache: use IntrusiveHashSet instead of
 boost::intrusive::unordered_set

---
 src/RemoteTagCache.cxx |  8 +++-----
 src/RemoteTagCache.hxx | 14 +++++---------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/RemoteTagCache.cxx b/src/RemoteTagCache.cxx
index 75723cab8..c351c349d 100644
--- a/src/RemoteTagCache.cxx
+++ b/src/RemoteTagCache.cxx
@@ -30,8 +30,7 @@ static constexpr Domain remote_tag_cache_domain("remote_tag_cache");
 RemoteTagCache::RemoteTagCache(EventLoop &event_loop,
 			       RemoteTagCacheHandler &_handler) noexcept
 	:handler(_handler),
-	 defer_invoke_handler(event_loop, BIND_THIS_METHOD(InvokeHandlers)),
-	 map(typename KeyMap::bucket_traits(&buckets.front(), buckets.size()))
+	 defer_invoke_handler(event_loop, BIND_THIS_METHOD(InvokeHandlers))
 {
 }
 
@@ -45,11 +44,10 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept
 {
 	std::unique_lock<Mutex> lock(mutex);
 
-	KeyMap::insert_commit_data hint;
-	auto [tag, value] = map.insert_check(uri, Item::Hash(), Item::Equal(), hint);
+	auto [tag, value] = map.insert_check(uri);
 	if (value) {
 		auto item = new Item(*this, uri);
-		map.insert_commit(*item, hint);
+		map.insert(tag, *item);
 		waiting_list.push_back(*item);
 		lock.unlock();
 
diff --git a/src/RemoteTagCache.hxx b/src/RemoteTagCache.hxx
index a2051a575..116a753b5 100644
--- a/src/RemoteTagCache.hxx
+++ b/src/RemoteTagCache.hxx
@@ -25,8 +25,7 @@
 #include "event/InjectEvent.hxx"
 #include "thread/Mutex.hxx"
 #include "util/IntrusiveList.hxx"
-
-#include <boost/intrusive/unordered_set.hpp>
+#include "util/IntrusiveHashSet.hxx"
 
 #include <string>
 
@@ -45,7 +44,7 @@ class RemoteTagCache final {
 	Mutex mutex;
 
 	struct Item final
-		: public boost::intrusive::unordered_set_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>,
+		: public IntrusiveHashSetHook<>,
 		  public IntrusiveListHook<>,
 		  RemoteTagHandler
 	{
@@ -113,12 +112,9 @@ class RemoteTagCache final {
 	 */
 	ItemList invoke_list;
 
-	typedef boost::intrusive::unordered_set<Item,
-						boost::intrusive::hash<Item::Hash>,
-						boost::intrusive::equal<Item::Equal>,
-						boost::intrusive::constant_time_size<true>> KeyMap;
-
-	std::array<typename KeyMap::bucket_type, 127> buckets;
+	using KeyMap = IntrusiveHashSet<Item, 127, Item::Hash, Item::Equal,
+					IntrusiveHashSetBaseHookTraits<Item>,
+					true>;
 
 	KeyMap map;