Skip to content

Commit

Permalink
[Iter] don't shuffle values
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <[email protected]>
  • Loading branch information
azjezz committed Jul 10, 2021
1 parent 0d1d182 commit 6f5c992
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Psl/Iter/random.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ function random(iterable $iterable)

Psl\invariant(0 !== $size, 'Expected a non-empty iterable.');

$shuffled = Vec\shuffle($values);

if (1 === $size) {
/** @var Tv */
return $shuffled[0];
return $values[0];
}

return $shuffled[PseudoRandom\int(0, $size - 1)];
return $values[PseudoRandom\int(0, $size - 1)];
}

0 comments on commit 6f5c992

Please sign in to comment.