Skip to content

Commit 0bbcf14

Browse files
committed
comments
1 parent 4466c2e commit 0bbcf14

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

libc/docs/configure.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ to learn about the defaults for your platform and target.
4545
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_DYADIC_FLOAT``: Use dyadic float for faster and smaller but less accurate printf doubles.
4646
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320``: Use an alternative printf float implementation based on 320-bit floats
4747
- ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE``: Use large table for better printf long double performance.
48-
- ``LIBC_CONF_PRINTF_RUNTIME_DISPATCH``: Use dynamic distpatch for conversion functions to reduce code size.
48+
- ``LIBC_CONF_PRINTF_RUNTIME_DISPATCH``: Use dynamic dispatch for the output mechanism to reduce code size.
4949
* **"pthread" options**
5050
- ``LIBC_CONF_RAW_MUTEX_DEFAULT_SPIN_COUNT``: Default number of spins before blocking if a mutex is in contention (default to 100).
5151
- ``LIBC_CONF_RWLOCK_DEFAULT_SPIN_COUNT``: Default number of spins before blocking if a rwlock is in contention (default to 100).

libc/src/stdio/printf_core/writer.h

+11-12
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,20 @@ template <WriteMode write_mode> struct WriteBuffer {
107107
// this with an empty string will flush the buffer if relevant.
108108

109109
LIBC_INLINE int overflow_write(cpp::string_view new_str) {
110-
#ifdef LIBC_COPT_PRINTF_RUNTIME_DISPATCH
111-
if (write_mode_ == WriteMode::FILL_BUFF_AND_DROP_OVERFLOW)
110+
if constexpr (write_mode == WriteMode::RUNTIME_DISPATCH) {
111+
if (write_mode_ == WriteMode::FILL_BUFF_AND_DROP_OVERFLOW)
112+
return fill_remaining_to_buff(new_str);
113+
else if (write_mode_ == WriteMode::FLUSH_TO_STREAM)
114+
return flush_to_stream(new_str);
115+
else if (write_mode_ == WriteMode::RESIZE_AND_FILL_BUFF)
116+
return resize_and_write(new_str);
117+
} else if constexpr (write_mode == WriteMode::FILL_BUFF_AND_DROP_OVERFLOW) {
112118
return fill_remaining_to_buff(new_str);
113-
else if (write_mode_ == WriteMode::FLUSH_TO_STREAM)
119+
} else if constexpr (write_mode == WriteMode::FLUSH_TO_STREAM) {
114120
return flush_to_stream(new_str);
115-
else if (write_mode_ == WriteMode::RESIZE_AND_FILL_BUFF)
121+
} else if constexpr (write_mode == WriteMode::RESIZE_AND_FILL_BUFF) {
116122
return resize_and_write(new_str);
117-
#else
118-
if constexpr (write_mode == WriteMode::FILL_BUFF_AND_DROP_OVERFLOW)
119-
return fill_remaining_to_buff(new_str);
120-
else if constexpr (write_mode == WriteMode::FLUSH_TO_STREAM)
121-
return flush_to_stream(new_str);
122-
else if constexpr (write_mode == WriteMode::RESIZE_AND_FILL_BUFF)
123-
return resize_and_write(new_str);
124-
#endif
123+
}
125124
__builtin_unreachable();
126125
}
127126
};

0 commit comments

Comments
 (0)