[PATCH] testbot: Simplify and speed up GenerateRandomString().
Perl's rand() function can return random values greater than 2^16 nowadays. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> --- testbot/lib/WineTestBot/Utils.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm index e8ba5162dc..27b222fd21 100644 --- a/testbot/lib/WineTestBot/Utils.pm +++ b/testbot/lib/WineTestBot/Utils.pm @@ -201,8 +201,8 @@ sub GenerateRandomString($) my $RandomString = ""; while (length($RandomString) < $Len) { - my $Part = "0000" . sprintf("%lx", int(rand(2 ** 16))); - $RandomString .= substr($Part, -4); + $RandomString .= sprintf("%08x", int(rand(2 ** 32))); + } return substr($RandomString, 0, $Len); -- 2.20.1
participants (1)
-
Francois Gouget