summaryrefslogtreecommitdiffstats
path: root/src/common/weighted_shuffle.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:13 +0000
commit389020e14594e4894e28d1eb9103c210b142509e (patch)
tree2ba734cdd7a243f46dda7c3d0cc88c2293d9699f /src/common/weighted_shuffle.h
parentAdding upstream version 18.2.2. (diff)
downloadceph-389020e14594e4894e28d1eb9103c210b142509e.tar.xz
ceph-389020e14594e4894e28d1eb9103c210b142509e.zip
Adding upstream version 18.2.3.upstream/18.2.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/common/weighted_shuffle.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/common/weighted_shuffle.h b/src/common/weighted_shuffle.h
index 10def0a01..dd8f22da0 100644
--- a/src/common/weighted_shuffle.h
+++ b/src/common/weighted_shuffle.h
@@ -14,6 +14,8 @@ void weighted_shuffle(RandomIt first, RandomIt last,
{
if (first == last) {
return;
+ } else if (std::accumulate(weight_first, weight_last, 0) == 0) {
+ return;
} else {
std::discrete_distribution d{weight_first, weight_last};
if (auto n = d(g); n > 0) {