Skip to content

Commit

Permalink
libtorrent: Use std::shuffle (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
stickz authored Jan 13, 2025
1 parent 9d73862 commit f93161f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libtorrent/src/torrent/tracker_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "config.h"

#include <functional>
#include <random>

#include "net/address_list.h"
#include "torrent/utils/log.h"
Expand Down Expand Up @@ -300,12 +301,14 @@ TrackerList::promote(iterator itr) {

void
TrackerList::randomize_group_entries() {
static std::random_device rd;
static std::mt19937 rng(rd());
// Random random random.
iterator itr = begin();

while (itr != end()) {
iterator tmp = end_group((*itr)->group());
std::random_shuffle(itr, tmp);
std::shuffle(itr, tmp, rng);

itr = tmp;
}
Expand Down

0 comments on commit f93161f

Please sign in to comment.