Remove the need for rand in core:math/big

This commit is contained in:
gingerBill
2024-06-15 15:43:57 +01:00
parent 7ec17ecf98
commit 149ecafdef
4 changed files with 13 additions and 16 deletions
+5 -5
View File
@@ -2817,11 +2817,11 @@ internal_platform_count_lsb :: #force_inline proc(a: $T) -> (count: int)
internal_count_lsb :: proc { internal_int_count_lsb, internal_platform_count_lsb, }
internal_int_random_digit :: proc(r: ^rnd.Rand = nil) -> (res: DIGIT) {
internal_int_random_digit :: proc() -> (res: DIGIT) {
when _DIGIT_BITS == 60 { // DIGIT = u64
return DIGIT(rnd.uint64(r)) & _MASK
return DIGIT(rnd.uint64()) & _MASK
} else when _DIGIT_BITS == 28 { // DIGIT = u32
return DIGIT(rnd.uint32(r)) & _MASK
return DIGIT(rnd.uint32()) & _MASK
} else {
panic("Unsupported DIGIT size.")
}
@@ -2829,7 +2829,7 @@ internal_int_random_digit :: proc(r: ^rnd.Rand = nil) -> (res: DIGIT) {
return 0 // We shouldn't get here.
}
internal_int_random :: proc(dest: ^Int, bits: int, r: ^rnd.Rand = nil, allocator := context.allocator) -> (err: Error) {
internal_int_random :: proc(dest: ^Int, bits: int, allocator := context.allocator) -> (err: Error) {
context.allocator = allocator
bits := bits
@@ -2846,7 +2846,7 @@ internal_int_random :: proc(dest: ^Int, bits: int, r: ^rnd.Rand = nil, allocator
#force_inline internal_grow(dest, digits) or_return
for i := 0; i < digits; i += 1 {
dest.digit[i] = int_random_digit(r) & _MASK
dest.digit[i] = int_random_digit() & _MASK
}
if bits > 0 {
dest.digit[digits - 1] &= ((1 << uint(bits)) - 1)