Skip to content

Commit

Permalink
Update: speed up Client::normalRandom() method
Browse files Browse the repository at this point in the history
  • Loading branch information
hidehalo committed Oct 3, 2018
1 parent 873355b commit 0f4ffdd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function formatedId($alphabet, $size, GeneratorInterface $generator = nul
private function normalRandom($size)
{
$id = '';
$bytes = $this->generator->random($size);
while (1 <= $size) {
$id .= $this->alphbet[$bytes[$size--] & 63];
while (1 <= $size--) {
$rand = mt_rand()/(mt_getrandmax() + 1);
$id .= $this->alphbet[$rand*64 | 0];
}

return $id;
Expand Down

0 comments on commit 0f4ffdd

Please sign in to comment.