[libc++][format][2/6] Adds a __output_iterator.
Instead of using a temporary `string` in `__vformat_to_wrapped` use a new
generic iterator. This aids to reduce the number of template instantions
and avoids using a `string` to buffer the entire formatted output.
This changes the type of `format_context` and `wformat_context`, this can
still be done since the code isn't ABI stable yet.
Several approaches have been evaluated:
- Using a __output_buffer base class with:
- a put function to store the buffer in its internal buffer
- a virtual flush function to copy the internal buffer to the output
- Using a `function` to forward the output operation to the output buffer,
much like the next method.
- Using a type erased function point to store the data in the buffer.
The last version resulted in the best performance. For some cases there's
still a loss of speed over the original method. This loss many becomes
apparent when large strings are copied to a pointer like iterator, before
the compiler optimized this using `memcpy`.
Reviewed By: ldionne, vitaut, #libc
Differential Revision: https://reviews.llvm.org/D110495
NOKEYCHECK=True
GitOrigin-RevId: 555214cbcc79eac401482e1a302f726b54182546
diff --git a/include/module.modulemap b/include/module.modulemap
index faf700d..b9d5fea 100644
--- a/include/module.modulemap
+++ b/include/module.modulemap
@@ -512,6 +512,7 @@
export *
module __format {
+ module buffer { private header "__format/buffer.h" }
module format_arg { private header "__format/format_arg.h" }
module format_args { private header "__format/format_args.h" }
module format_context {