Skip to content

Commit 4e860d7

Browse files
fix more nits
1 parent 746a300 commit 4e860d7

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

libc/src/__support/float_to_string.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,13 @@ class FloatToString {
572572
}
573573

574574
LIBC_INLINE constexpr size_t get_positive_blocks() {
575-
if (exponent >= -FRACTION_LEN) {
576-
const uint32_t idx =
577-
exponent < 0
578-
? 0
579-
: static_cast<uint32_t>(exponent + (IDX_SIZE - 1)) / IDX_SIZE;
580-
const uint32_t len =
581-
internal::length_for_num(idx * IDX_SIZE, FRACTION_LEN);
582-
return len;
583-
} else {
575+
if (exponent < -FRACTION_LEN)
584576
return 0;
585-
}
577+
const uint32_t idx =
578+
exponent < 0
579+
? 0
580+
: static_cast<uint32_t>(exponent + (IDX_SIZE - 1)) / IDX_SIZE;
581+
return internal::length_for_num(idx * IDX_SIZE, FRACTION_LEN);
586582
}
587583

588584
// This takes the index of a block after the decimal point (a negative block)
@@ -614,7 +610,7 @@ class FloatToString {
614610
internal::ceil_log10_pow2(FRACTION_LEN + 1)) /
615611
BLOCK_SIZE) -
616612
1;
617-
return len = static_cast<uint32_t>(pos_len > 0 ? pos_len : 0);
613+
return static_cast<uint32_t>(pos_len > 0 ? pos_len : 0);
618614
}
619615
return 0;
620616
#else
@@ -668,9 +664,8 @@ template <> class FloatToString<long double> {
668664
cpp::UInt<FLOAT_AS_INT_WIDTH + EXTRA_INT_WIDTH> &int_num) {
669665
// WORD_SIZE is the width of the numbers used to internally represent the
670666
// UInt
671-
for (size_t i = 0; i < EXTRA_INT_WIDTH / int_num.WORD_SIZE; ++i) {
667+
for (size_t i = 0; i < EXTRA_INT_WIDTH / int_num.WORD_SIZE; ++i)
672668
int_num[i + (FLOAT_AS_INT_WIDTH / int_num.WORD_SIZE)] = 0;
673-
}
674669
}
675670

676671
// init_convert initializes float_as_int, cur_block, and block_buffer based on
@@ -775,7 +770,7 @@ template <> class FloatToString<long double> {
775770
LIBC_INLINE constexpr bool is_lowest_block(size_t negative_block_index) {
776771
// The decimal representation of 2**(-i) will have exactly i digits after
777772
// the decimal point.
778-
int num_requested_digits =
773+
const int num_requested_digits =
779774
static_cast<int>((negative_block_index + 1) * BLOCK_SIZE);
780775

781776
return num_requested_digits > -exponent;
@@ -798,7 +793,7 @@ template <> class FloatToString<long double> {
798793
// point, and 1 with the second and so on. This converts to the same
799794
// block_index used everywhere else.
800795

801-
int block_index = -1 - negative_block_index;
796+
const int block_index = -1 - negative_block_index;
802797

803798
// If we're currently after the requested block (remember these are
804799
// negative indices) we reset the number to the start. This is only

0 commit comments

Comments
 (0)