@@ -103,14 +103,14 @@ class PaddingWriter {
103
103
size_t min_width = 0 ;
104
104
105
105
public:
106
- PaddingWriter () {}
107
- PaddingWriter (const FormatSection &to_conv, char init_sign_char)
106
+ LIBC_INLINE PaddingWriter () {}
107
+ LIBC_INLINE PaddingWriter (const FormatSection &to_conv, char init_sign_char)
108
108
: left_justified((to_conv.flags & FormatFlags::LEFT_JUSTIFIED) > 0),
109
109
leading_zeroes((to_conv.flags & FormatFlags::LEADING_ZEROES) > 0),
110
110
sign_char(init_sign_char),
111
111
min_width(to_conv.min_width > 0 ? to_conv.min_width : 0 ) {}
112
112
113
- int write_left_padding (Writer *writer, size_t total_digits) {
113
+ LIBC_INLINE int write_left_padding (Writer *writer, size_t total_digits) {
114
114
// The pattern is (spaces) (sign) (zeroes), but only one of spaces and
115
115
// zeroes can be written, and only if the padding amount is positive.
116
116
int padding_amount =
@@ -133,7 +133,7 @@ class PaddingWriter {
133
133
return 0 ;
134
134
}
135
135
136
- int write_right_padding (Writer *writer, size_t total_digits) {
136
+ LIBC_INLINE int write_right_padding (Writer *writer, size_t total_digits) {
137
137
// If and only if the conversion is left justified, there may be trailing
138
138
// spaces.
139
139
int padding_amount =
@@ -170,7 +170,7 @@ class FloatWriter {
170
170
Writer *writer; // Writes to the final output.
171
171
PaddingWriter padding_writer; // Handles prefixes/padding, uses total_digits.
172
172
173
- int flush_buffer (bool round_up_max_blocks = false ) {
173
+ LIBC_INLINE int flush_buffer (bool round_up_max_blocks = false ) {
174
174
const char MAX_BLOCK_DIGIT = (round_up_max_blocks ? ' 0' : ' 9' );
175
175
176
176
// Write the most recent buffered block, and mark has_written
@@ -249,17 +249,18 @@ class FloatWriter {
249
249
(sizeof (int ) * 8 ));
250
250
251
251
public:
252
- FloatWriter (Writer *init_writer, bool init_has_decimal_point,
253
- const PaddingWriter &init_padding_writer)
252
+ LIBC_INLINE FloatWriter (Writer *init_writer, bool init_has_decimal_point,
253
+ const PaddingWriter &init_padding_writer)
254
254
: has_decimal_point(init_has_decimal_point), writer(init_writer),
255
255
padding_writer(init_padding_writer) {}
256
256
257
- void init (size_t init_total_digits, size_t init_digits_before_decimal) {
257
+ LIBC_INLINE void init (size_t init_total_digits,
258
+ size_t init_digits_before_decimal) {
258
259
total_digits = init_total_digits;
259
260
digits_before_decimal = init_digits_before_decimal;
260
261
}
261
262
262
- void write_first_block (BlockInt block, bool exp_format = false ) {
263
+ LIBC_INLINE void write_first_block (BlockInt block, bool exp_format = false ) {
263
264
const DecimalString buf (block);
264
265
const cpp::string_view int_to_str = buf.view ();
265
266
size_t digits_buffered = int_to_str.size ();
@@ -280,7 +281,7 @@ class FloatWriter {
280
281
}
281
282
}
282
283
283
- int write_middle_block (BlockInt block) {
284
+ LIBC_INLINE int write_middle_block (BlockInt block) {
284
285
if (block == MAX_BLOCK) { // Buffer max blocks in case of rounding
285
286
++max_block_count;
286
287
} else { // If a non-max block has been found
@@ -301,9 +302,9 @@ class FloatWriter {
301
302
return 0 ;
302
303
}
303
304
304
- int write_last_block (BlockInt block, size_t block_digits,
305
- RoundDirection round, int exponent = 0 ,
306
- char exp_char = ' \0 ' ) {
305
+ LIBC_INLINE int write_last_block (BlockInt block, size_t block_digits,
306
+ RoundDirection round, int exponent = 0 ,
307
+ char exp_char = ' \0 ' ) {
307
308
bool has_exp = (exp_char != ' \0 ' );
308
309
309
310
char end_buff[BLOCK_SIZE];
@@ -458,13 +459,13 @@ class FloatWriter {
458
459
return WRITE_OK;
459
460
}
460
461
461
- int write_zeroes (uint32_t num_zeroes) {
462
+ LIBC_INLINE int write_zeroes (uint32_t num_zeroes) {
462
463
RET_IF_RESULT_NEGATIVE (flush_buffer ());
463
464
RET_IF_RESULT_NEGATIVE (writer->write (' 0' , num_zeroes));
464
465
return 0 ;
465
466
}
466
467
467
- int right_pad () {
468
+ LIBC_INLINE int right_pad () {
468
469
return padding_writer.write_right_padding (writer, total_digits);
469
470
}
470
471
};
0 commit comments