Revert weighted shuffle algorithm change (#3823)

This commit is contained in:
Vaalyn 2021-02-16 23:38:10 +01:00 committed by GitHub
parent 4153529a2f
commit 78012a1401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -228,18 +228,21 @@ class Queue implements EventSubscriberInterface
{
$new = $original;
$max = 1.0 / mt_getrandmax();
array_walk(
$new,
function (&$v, $k): void {
$v = random_int(1, $v);
function (&$value, $key) use ($max): void {
$value = (mt_rand() * $max) ** (1.0 / $value);
}
);
arsort($new);
array_walk(
$new,
function (&$v, $k) use ($original): void {
$v = $original[$k];
function (&$value, $key) use ($original): void {
$value = $original[$key];
}
);