1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: add missing pub modifiers for .byte() and .u32() methods (#13992)

This commit is contained in:
Subhomoy Haldar 2022-04-10 14:13:46 +05:30 committed by GitHub
parent 11d9a67e3b
commit 3f90809035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ pub fn (mut rng MuslRNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
fn (mut rng MuslRNG) byte() byte { pub fn (mut rng MuslRNG) byte() byte {
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1
value := byte(rng.buffer) value := byte(rng.buffer)
@ -70,7 +70,7 @@ fn temper(prev u32) u32 {
} }
// u32 returns a pseudorandom 32-bit unsigned integer (`u32`). // u32 returns a pseudorandom 32-bit unsigned integer (`u32`).
fn (mut rng MuslRNG) u32() u32 { pub fn (mut rng MuslRNG) u32() u32 {
rng.state = rng.state * 1103515245 + 12345 rng.state = rng.state * 1103515245 + 12345
// We are not dividing by 2 (or shifting right by 1) // We are not dividing by 2 (or shifting right by 1)
// because we want all 32-bits of random data // because we want all 32-bits of random data

View File

@ -39,7 +39,7 @@ pub fn (mut rng PCG32RNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
fn (mut rng PCG32RNG) byte() byte { pub fn (mut rng PCG32RNG) byte() byte {
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1
value := byte(rng.buffer) value := byte(rng.buffer)
@ -70,7 +70,7 @@ pub fn (mut rng PCG32RNG) u16() u16 {
// u32 returns a pseudorandom unsigned `u32`. // u32 returns a pseudorandom unsigned `u32`.
[inline] [inline]
fn (mut rng PCG32RNG) u32() u32 { pub fn (mut rng PCG32RNG) u32() u32 {
oldstate := rng.state oldstate := rng.state
rng.state = oldstate * (6364136223846793005) + rng.inc rng.state = oldstate * (6364136223846793005) + rng.inc
xorshifted := u32(((oldstate >> u64(18)) ^ oldstate) >> u64(27)) xorshifted := u32(((oldstate >> u64(18)) ^ oldstate) >> u64(27))