Use normal i64 arithmetic instead of big-ints for hot path

This commit is contained in:
gingerBill
2026-03-17 13:34:06 +00:00
parent 46936e0e52
commit 153a522228
3 changed files with 66 additions and 14 deletions

View File

@@ -57,6 +57,8 @@ gb_internal void big_int_dealloc(BigInt *dst) {
mp_clear(dst);
}
gb_internal bool big_int_can_be_represented_in_64_bits(BigInt const *x);
gb_internal BigInt big_int_make(BigInt const *b, bool abs=false);
gb_internal BigInt big_int_make_abs(BigInt const *b);
gb_internal BigInt big_int_make_u64(u64 x);
@@ -293,6 +295,11 @@ gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success
gb_internal bool big_int_can_be_represented_in_64_bits(BigInt const *x) {
int bits_used = (x->used-1) * MP_DIGIT_BIT;
return bits_used <= 64;
}
gb_internal u64 big_int_to_u64(BigInt const *x) {
GB_ASSERT(x->sign == 0);
return mp_get_u64(x);