[libcxx-commits] [PATCH] D110495: [libc++][format][2/6] Adds a __output_iterator.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 25 11:25:35 PST 2021


Mordante added inline comments.


================
Comment at: libcxx/include/__format/buffer.h:57-59
+        __flush_([](_CharT* __ptr, size_t __size, void* __o) {
+          static_cast<_Tp*>(__o)->flush(__ptr, __size);
+        }),
----------------
vitaut wrote:
> As discussed in D112361, it would be good to avoid extra buffering for the common case of appending to a contiguous container such as string or vector.
What do you mean with "appending"?
`std::back_inserter(std::string)` or `std::string::begin()`

I think it makes sense to buffer the `back_inserter`. For example every `push_back` in a `std::string` NUL-terminates the string. The `insert` operation does one NUL-termination.

D110497 changes the behaviour for these containers to buffer in this object and then use `insert` in these containers.

But I can test with the benchmarks whether the extra buffering has a positive or negative effect.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110495/new/

https://reviews.llvm.org/D110495



More information about the libcxx-commits mailing list