Skip to content

Commit 1c6c1b5

Browse files
committed
remove redundent if
1 parent 806f26b commit 1c6c1b5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

libc/src/stdio/printf_core/float_dec_converter.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,10 @@ template <WriteMode write_mode> class FloatWriter {
186186
if (total_digits_written < digits_before_decimal &&
187187
total_digits_written + buffered_digits >= digits_before_decimal &&
188188
has_decimal_point) {
189+
// digits_to_write > 0 guaranteed by outer if
189190
size_t digits_to_write = digits_before_decimal - total_digits_written;
190-
if (digits_to_write > 0) {
191-
// Write the digits before the decimal point.
192-
RET_IF_RESULT_NEGATIVE(writer->write({block_buffer, digits_to_write}));
193-
}
191+
// Write the digits before the decimal point.
192+
RET_IF_RESULT_NEGATIVE(writer->write({block_buffer, digits_to_write}));
194193
RET_IF_RESULT_NEGATIVE(writer->write(DECIMAL_POINT));
195194
if (buffered_digits > digits_to_write) {
196195
// Write the digits after the decimal point.
@@ -217,10 +216,9 @@ template <WriteMode write_mode> class FloatWriter {
217216
total_digits_written + BLOCK_SIZE * max_block_count >=
218217
digits_before_decimal &&
219218
has_decimal_point) {
219+
// digits_to_write > 0 guaranteed by outer if
220220
size_t digits_to_write = digits_before_decimal - total_digits_written;
221-
if (digits_to_write > 0) {
222-
RET_IF_RESULT_NEGATIVE(writer->write(MAX_BLOCK_DIGIT, digits_to_write));
223-
}
221+
RET_IF_RESULT_NEGATIVE(writer->write(MAX_BLOCK_DIGIT, digits_to_write));
224222
RET_IF_RESULT_NEGATIVE(writer->write(DECIMAL_POINT));
225223
if ((BLOCK_SIZE * max_block_count) > digits_to_write) {
226224
RET_IF_RESULT_NEGATIVE(writer->write(

0 commit comments

Comments
 (0)