Browse Source

use runtime.random_generator_read_bytes in read procedure instead of filling it manually.

Xotchkass 1 month ago
parent
commit
df849891c1
1 changed files with 2 additions and 12 deletions
  1. 2 12
      core/math/rand/rand.odin

+ 2 - 12
core/math/rand/rand.odin

@@ -508,18 +508,8 @@ Possible Output:
 */
 */
 @(require_results)
 @(require_results)
 read :: proc(p: []byte, gen := context.random_generator) -> (n: int) {
 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)
 }
 }
 
 
 /*
 /*