mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Merge remote-tracking branch 'origin/topic/johanna/rand64bit'
* origin/topic/johanna/rand64bit: Optimize 64 bit random number generation
This commit is contained in:
commit
1c3c88fd2a
3 changed files with 14 additions and 3 deletions
10
CHANGES
10
CHANGES
|
@ -1,3 +1,13 @@
|
|||
5.1.0-dev.144 | 2022-06-30 13:37:40 -0700
|
||||
|
||||
* Optimize 64 bit random number generation (Johanna Amann)
|
||||
|
||||
rand64bit called random 4 times to generate one 64 bit number. There is
|
||||
no reason to do this - random() is basically guaranteed to return a 32
|
||||
bit number.
|
||||
|
||||
This also adds a static check to make sure that it does.
|
||||
|
||||
5.1.0-dev.142 | 2022-06-30 12:27:42 -0700
|
||||
|
||||
* Remove other general deprecations (Tim Wojtulewicz, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
5.1.0-dev.142
|
||||
5.1.0-dev.144
|
||||
|
|
|
@ -544,8 +544,9 @@ uint64_t rand64bit()
|
|||
uint64_t base = 0;
|
||||
int i;
|
||||
|
||||
for ( i = 1; i <= 4; ++i )
|
||||
base = (base << 16) | detail::random_number();
|
||||
static_assert(RAND_MAX == 2147483647); // 2^32-1
|
||||
for ( i = 1; i <= 2; ++i )
|
||||
base = (base << 32) | detail::random_number();
|
||||
return base;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue