diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-11-27 10:24:22 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-11-27 10:24:22 +0000 |
| commit | 78d8059ebebda8b9bcd4959d804e1bab7d0254e7 (patch) | |
| tree | 2a156f9d871104936e2c39eec8d3692a8da81ab7 /core/math/big | |
| parent | bf43dbaf5a65bbf6fcaf0d2389da703cbc364614 (diff) | |
Use `@(rodata)` where possible
Diffstat (limited to 'core/math/big')
| -rw-r--r-- | core/math/big/internal.odin | 3 | ||||
| -rw-r--r-- | core/math/big/prime.odin | 3 | ||||
| -rw-r--r-- | core/math/big/private.odin | 5 | ||||
| -rw-r--r-- | core/math/big/radix.odin | 9 |
4 files changed, 14 insertions, 6 deletions
diff --git a/core/math/big/internal.odin b/core/math/big/internal.odin index 4bb45397d..333fee3ad 100644 --- a/core/math/big/internal.odin +++ b/core/math/big/internal.odin @@ -2791,7 +2791,8 @@ internal_int_count_lsb :: proc(a: ^Int) -> (count: int, err: Error) { x *= _DIGIT_BITS x += internal_count_lsb(q) } else { - lnz := []int{ + @(static, rodata) + lnz := [?]int{ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, } diff --git a/core/math/big/prime.odin b/core/math/big/prime.odin index 4fe502a20..1c772143b 100644 --- a/core/math/big/prime.odin +++ b/core/math/big/prime.odin @@ -134,7 +134,8 @@ internal_int_kronecker :: proc(a, p: ^Int, allocator := context.allocator) -> (k a1, p1, r := &Int{}, &Int{}, &Int{} defer internal_destroy(a1, p1, r) - table := []int{0, 1, 0, -1, 0, -1, 0, 1} + @(static, rodata) + table := [?]int{0, 1, 0, -1, 0, -1, 0, 1} if internal_int_is_zero(p) { if a.used == 1 && a.digit[0] == 1 { diff --git a/core/math/big/private.odin b/core/math/big/private.odin index 2814b5429..caed8c8b9 100644 --- a/core/math/big/private.odin +++ b/core/math/big/private.odin @@ -3217,6 +3217,7 @@ _private_int_shr_leg :: proc(quotient: ^Int, digits: int, allocator := context.a Tables used by `internal_*` and `_*`. */ +@(rodata) _private_int_rem_128 := [?]DIGIT{ 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, @@ -3229,6 +3230,7 @@ _private_int_rem_128 := [?]DIGIT{ } #assert(128 * size_of(DIGIT) == size_of(_private_int_rem_128)) +@(rodata) _private_int_rem_105 := [?]DIGIT{ 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, @@ -3241,6 +3243,7 @@ _private_int_rem_105 := [?]DIGIT{ #assert(105 * size_of(DIGIT) == size_of(_private_int_rem_105)) _PRIME_TAB_SIZE :: 256 +@(rodata) _private_prime_table := [_PRIME_TAB_SIZE]DIGIT{ 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, @@ -3281,6 +3284,7 @@ _private_prime_table := [_PRIME_TAB_SIZE]DIGIT{ #assert(_PRIME_TAB_SIZE * size_of(DIGIT) == size_of(_private_prime_table)) when MATH_BIG_FORCE_64_BIT || (!MATH_BIG_FORCE_32_BIT && size_of(rawptr) == 8) { + @(rodata) _factorial_table := [35]_WORD{ /* f(00): */ 1, /* f(01): */ 1, @@ -3319,6 +3323,7 @@ when MATH_BIG_FORCE_64_BIT || (!MATH_BIG_FORCE_32_BIT && size_of(rawptr) == 8) { /* f(34): */ 295_232_799_039_604_140_847_618_609_643_520_000_000, } } else { + @(rodata) _factorial_table := [21]_WORD{ /* f(00): */ 1, /* f(01): */ 1, diff --git a/core/math/big/radix.odin b/core/math/big/radix.odin index a7f93b990..4e491e4a0 100644 --- a/core/math/big/radix.odin +++ b/core/math/big/radix.odin @@ -357,8 +357,7 @@ radix_size :: proc(a: ^Int, radix: i8, zero_terminate := false, allocator := con internal_set(la, bit_count) or_return /* k = floor(2^29/log_2(radix)) + 1 */ - lb := _log_bases - internal_set(k, lb[radix]) or_return + internal_set(k, _log_bases[radix]) or_return /* n = floor((la * k) / 2^29) + 1 */ internal_mul(k, la, k) or_return @@ -564,8 +563,9 @@ internal_int_unpack :: proc(a: ^Int, buf: []$T, nails := 0, order := Order.LSB_F */ _RADIX_SIZE_SCALE :: 29 -_log_bases :: [65]u32{ - 0, 0, 0x20000001, 0x14309399, 0x10000001, +@(rodata) +_log_bases := [65]u32{ + 0, 0, 0x20000001, 0x14309399, 0x10000001, 0xdc81a35, 0xc611924, 0xb660c9e, 0xaaaaaab, 0xa1849cd, 0x9a209a9, 0x94004e1, 0x8ed19c2, 0x8a5ca7d, 0x867a000, 0x830cee3, 0x8000001, 0x7d42d60, 0x7ac8b32, 0x7887847, @@ -584,6 +584,7 @@ _log_bases :: [65]u32{ Characters used in radix conversions. */ RADIX_TABLE := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/" +@(rodata) RADIX_TABLE_REVERSE := [RADIX_TABLE_REVERSE_SIZE]u8{ 0x3e, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x01, 0x02, 0x03, 0x04, /* +,-./01234 */ 0x05, 0x06, 0x07, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, /* 56789:;<=> */ |