diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-11-27 15:35:05 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-11-27 15:35:05 +0100 |
| commit | 1ea5990be22994ad4d740f5d47da27780c6a1efc (patch) | |
| tree | 35794ef251209763a7af925220f163204c8324f4 /core/math/big/common.odin | |
| parent | 78d8059ebebda8b9bcd4959d804e1bab7d0254e7 (diff) | |
Speed up big.itoa
Extract 18 (64-bit) or 8 (32-bit) digits per big division.
This gives a 2.5x speedup for a 1024-bit bigint.
Diffstat (limited to 'core/math/big/common.odin')
| -rw-r--r-- | core/math/big/common.odin | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/math/big/common.odin b/core/math/big/common.odin index f6485f3fb..944d1cfa1 100644 --- a/core/math/big/common.odin +++ b/core/math/big/common.odin @@ -223,9 +223,15 @@ when MATH_BIG_FORCE_64_BIT || (!MATH_BIG_FORCE_32_BIT && size_of(rawptr) == 8) { */ DIGIT :: distinct u64 _WORD :: distinct u128 + // Base 10 extraction constants + ITOA_DIVISOR :: DIGIT(1_000_000_000_000_000_000) + ITOA_COUNT :: 18 } else { DIGIT :: distinct u32 _WORD :: distinct u64 + // Base 10 extraction constants + ITOA_DIVISOR :: DIGIT(100_000_000) + ITOA_COUNT :: 8 } #assert(size_of(_WORD) == 2 * size_of(DIGIT)) |