daemon: Replace ‘random_shuffle’ with ‘shuffle’.

‘std::random_shuffle’ was removed in C++14.

* nix/libstore/gc.cc (LocalStore::collectGarbage): Use ‘std::random’ and
‘std::shuffle’.

Change-Id: If91ed3ec3596a419ae7c87d7ce677e0970853e9f
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Congcong Kuo 2025-05-11 16:31:22 +08:00 committed by Ludovic Courtès
parent 437bb9ece5
commit 5f3518ca83
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -4,6 +4,7 @@
#include <functional>
#include <queue>
#include <random>
#include <algorithm>
#include <sys/types.h>
@ -745,7 +746,9 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
alphabetically first (e.g. /nix/store/000...). This
matters when using --max-freed etc. */
vector<Path> entries_(entries.begin(), entries.end());
random_shuffle(entries_.begin(), entries_.end());
std::random_device seeder;
std::default_random_engine generator(seeder());
std::shuffle(entries_.begin(), entries_.end(), generator);
foreach (vector<Path>::iterator, i, entries_)
tryToDelete(state, *i);