mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-25 23:14:59 -07:00
use runtime.random_generator_read_bytes in read procedure instead of filling it manually.
This commit is contained in:
@@ -508,18 +508,8 @@ Possible Output:
|
||||
*/
|
||||
@(require_results)
|
||||
read :: proc(p: []byte, gen := context.random_generator) -> (n: int) {
|
||||
pos := i8(0)
|
||||
val := i64(0)
|
||||
for n = 0; n < len(p); n += 1 {
|
||||
if pos == 0 {
|
||||
val = int63(gen)
|
||||
pos = 7
|
||||
}
|
||||
p[n] = byte(val)
|
||||
val >>= 8
|
||||
pos -= 1
|
||||
}
|
||||
return
|
||||
if !runtime.random_generator_read_bytes(gen, p) {return 0}
|
||||
return len(p)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user