Skip to content

Commit dc831a9

Browse files
committed
fixup! [libc] Optimize BigInt→decimal in IntegerToString
1 parent b9168b8 commit dc831a9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libc/src/__support/integer_to_string.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ LIBC_INLINE uint8_t extract_decimal_digit(T &value) {
215215
// all powers of 16 (larger than 1) are congruent to 6 mod 10, by induction:
216216
// 16 itself is, and 6^2=36 is also congruent to 6.
217217
Word acc_remainder = 0;
218-
const Word HALFWORD_BITS = T::WORD_SIZE / 2;
219-
const Word HALFWORD_MASK = ((Word(1) << HALFWORD_BITS) - 1);
218+
constexpr Word HALFWORD_BITS = T::WORD_SIZE / 2;
219+
constexpr Word HALFWORD_MASK = ((Word(1) << HALFWORD_BITS) - 1);
220220
// Sum both halves of all words except the low one.
221221
for (size_t i = 1; i < T::WORD_COUNT; i++) {
222222
acc_remainder += value.val[i] >> HALFWORD_BITS;
@@ -297,7 +297,7 @@ LIBC_INLINE uint8_t extract_decimal_digit(T &value) {
297297
// We do this entire procedure in a single in-place pass over the input
298298
// number, reading each word to make its product with C and then adding the
299299
// low word of the accumulator to it.
300-
const Word C = (Word(0) - 1) / 5 * 4; // calculate 0xCCCC as 4/5 of 0xFFFF
300+
constexpr Word C = Word(-1) / 5 * 4; // calculate 0xCCCC as 4/5 of 0xFFFF
301301
Word acc_lo = 0, acc_hi = 0; // accumulator of all the half-products so far
302302
Word carry_bit, carry_word = 0;
303303

0 commit comments

Comments
 (0)