diff options
author | Congcong Kuo <congcong.kuo@gmail.com> | 2025-05-11 16:31:22 +0800 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-05-12 10:40:02 +0200 |
commit | 5f3518ca83ad22cd77f24a05110c52907a46565d (patch) | |
tree | 8e9126cb2c28d4350e8382a4715135e6bdd38abc | |
parent | 437bb9ece55f37d4b5a62cafc98c0c3b848a53ce (diff) | |
download | guix-5f3518ca83ad22cd77f24a05110c52907a46565d.tar.gz guix-5f3518ca83ad22cd77f24a05110c52907a46565d.zip |
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>
-rw-r--r-- | nix/libstore/gc.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc index 16519116e4..261ea79ab3 100644 --- a/nix/libstore/gc.cc +++ b/nix/libstore/gc.cc @@ -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); |