Improve printf("%d") speed.

This commit is contained in:
Christoffer Lerno
2025-11-28 17:04:04 +01:00
parent 2df51bfe07
commit 0a0e097bdf
2 changed files with 64 additions and 14 deletions

View File

@@ -522,16 +522,16 @@ fn usz? BigInt.to_format(&self, Formatter* format) @dynamic
len++;
a.negate();
}
uint[280] chunks;
uint[280] chunks @noinit;
int chunk_count;
const BASE10_9 = 1000000000;
foreach_r(d : self.data)
foreach_r(d : self.data[:self.len])
{
ulong carry = d;
for (int i = 0; i < chunk_count; i++)
{
ulong v = chunks[i] * 4294967296ULL + carry;
ulong v = (ulong)chunks[i] << 32 + carry;
carry = v / BASE10_9;
chunks[i] = (uint)(v - carry * BASE10_9);
}
@@ -551,11 +551,6 @@ fn usz? BigInt.to_format(&self, Formatter* format) @dynamic
return len;
}
fn String BigInt.to_string(&self, Allocator allocator) @dynamic
{
return self.to_string_with_radix(10, allocator);
}
<*
@require radix > 1 && radix <= 36 : "Radix must be 2-36"
*>