Add fmt::print() overload to support compiled format (FMT_COMPILE) - #2304
Conversation
|
Thanks for the PR. In general looks good but I wonder if it's worth doing considering that format string processing time is likely small compared to I/O. Could you provide some benchmarks? |
|
Okay, I have the results, and there are some improvements. It worth noting though that these results may be too specific for my PC. Using static library:
Using header-only library:
Here a short notes about each benchmark:
|
| memory_buffer buffer; | ||
| detail::vformat_to(buffer, format_str, args); | ||
| namespace detail { | ||
| FMT_FUNC void print_buffer(std::FILE* f, const memory_buffer& buffer) { |
There was a problem hiding this comment.
I think it would be slightly better to pass the text as a string_view instead of a buffer. This also means that the name would have to change. Maybe detail::print?
There was a problem hiding this comment.
Done, the most challenging part of this change was to name the new argument correctly 😄, but since you mentioned that it's the text, I used text as a name.
Thanks for the benchmarks, they look convincing. |
effd732 to
16f9d54
Compare
Resolves #2280.
By adding a new exported function -
detail::print_buffer(std::FILE*, const memory_buffer&). This function is used in bothvprint()fromformat-inl.hand a newprint()fromcompile.h.