[libcxx-commits] [PATCH] D112361: [libc++][format] Buffer changes proof-of-concept

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 13 09:13:16 PST 2021


Mordante marked 9 inline comments as done.
Mordante added inline comments.


================
Comment at: libcxx/include/__format/buffer.h:60-61
+
+  template <class _Storage>
+  _LIBCPP_HIDE_FROM_ABI void reset(_Storage& __storage) {
+    __ptr_ = __storage.begin();
----------------
vitaut wrote:
> Looks like this doesn't need to be a template because it is only called with internal storage. 
Good point, I changed the call to just give the new values for `__ptr_` and `__capacity_` as argument.


================
Comment at: libcxx/include/__format/buffer.h:134-140
+  _CharT* __ptr_;
+  /// The capacity of the storage space.
+  ///
+  /// Normally the code expects the direct storage to have an infinite size.
+  /// The limit is used in format_to_n to limit the number of writes to the
+  /// underlying output.
+  size_t __capacity_;
----------------
vitaut wrote:
> `__ptr_` and `__capacity_` duplicate members of `__format_buffer`. Is it possible to get rid of them?
An interesting observation. I've tested it and these members are indeed not required. This means the entire class can just be an empty class. Since `__format_buffer` still needs to select between this storage and the `__interal_storage` it can't be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112361



More information about the libcxx-commits mailing list