[network/libktorrent] src/dht: Remove KBucketEntrySet as std::set has a contains() function since C++20
Jack Hill <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 3253990f96b92b17a8a00c734bab88b65a7b107f by Jack Hill.
Committed on 01/08/2026 at 11:11.
Pushed by jackh into branch 'master'.
Remove KBucketEntrySet as std::set has a contains() function since C++20
M +1 -1 src/dht/announcetask.cpp
M +1 -1 src/dht/announcetask.h
M +0 -21 src/dht/kbucketentry.h
M +1 -1 src/dht/nodelookup.cpp
M +2 -2 src/dht/task.h
https://invent.kde.org/network/libktorrent/-/commit/3253990f96b92b17a8a00c734bab88b65a7b107f
diff --git a/src/dht/announcetask.cpp b/src/dht/announcetask.cpp
index 2ae31164..82678336 100644
--- a/src/dht/announcetask.cpp
+++ b/src/dht/announcetask.cpp
@@ -117,7 +117,7 @@ void AnnounceTask::update()
// go over the todo list and send get_peers requests
// until we have nothing left
while (!todo.empty() && canDoRequest()) {
- const KBucketEntrySet::iterator itr = todo.begin();
+ const auto itr = todo.begin();
// onLy send a findNode if we haven't allrready visited the node
if (!visited.contains(*itr)) {
// send a findNode to the node
diff --git a/src/dht/announcetask.h b/src/dht/announcetask.h
index c43d0994..66c4f542 100644
--- a/src/dht/announcetask.h
+++ b/src/dht/announcetask.h
@@ -70,7 +70,7 @@ private:
dht::Key info_hash;
bt::Uint16 port;
std::set<KBucketEntryAndToken> answered; // nodes which have answered with values
- KBucketEntrySet answered_visited; // nodes which have answered with values which have been visited
+ std::set<dht::KBucketEntry> answered_visited; // nodes which have answered with values which have been visited
Database *db;
DBItemList returned_items;
};
diff --git a/src/dht/kbucketentry.h b/src/dht/kbucketentry.h
index e15534ca..53a14868 100644
--- a/src/dht/kbucketentry.h
+++ b/src/dht/kbucketentry.h
@@ -102,27 +102,6 @@ private:
bt::Uint32 failed_queries;
bt::Uint32 questionable_pings;
};
-
-/*!
- * \headerfile dht/kbucketentry.h
- * \brief Convenience wrapper around a std::set of KBucketEntry.
- */
-class KBucketEntrySet : public std::set<KBucketEntry>
-{
-public:
- KBucketEntrySet()
- {
- }
- virtual ~KBucketEntrySet()
- {
- }
-
- [[nodiscard]] bool contains(const KBucketEntry &entry) const
- {
- return find(entry) != end();
- }
-};
-
}
#endif // DHT_KBUCKETENTRY_H
diff --git a/src/dht/nodelookup.cpp b/src/dht/nodelookup.cpp
index 1b89f962..c816a33e 100644
--- a/src/dht/nodelookup.cpp
+++ b/src/dht/nodelookup.cpp
@@ -85,7 +85,7 @@ void NodeLookup::update()
// go over the todo list and send find node calls
// until we have nothing left
while (!todo.empty() && canDoRequest()) {
- const KBucketEntrySet::iterator itr = todo.begin();
+ const auto itr = todo.begin();
// only send a findNode if we haven't allrready visited the node
if (!visited.contains(*itr)) {
// send a findNode to the node
diff --git a/src/dht/task.h b/src/dht/task.h
index 3aafa0d4..d33842cd 100644
--- a/src/dht/task.h
+++ b/src/dht/task.h
@@ -146,8 +146,8 @@ protected Q_SLOTS:
void onResolverResults(net::AddressResolver *res);
protected:
- dht::KBucketEntrySet visited; // nodes visited
- dht::KBucketEntrySet todo; // nodes todo
+ std::set<dht::KBucketEntry> visited; // nodes visited
+ std::set<dht::KBucketEntry> todo; // nodes todo
Node *node;
private: