[libcxx-commits] [PATCH] D125610: [NFC][libc++][format] Improves naming.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 14 09:18:09 PDT 2022


Mordante created this revision.
Mordante added a reviewer: ldionne.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Based on review comments in D110499 <https://reviews.llvm.org/D110499>.

Depends on D110499 <https://reviews.llvm.org/D110499>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125610

Files:
  libcxx/include/__format/buffer.h


Index: libcxx/include/__format/buffer.h
===================================================================
--- libcxx/include/__format/buffer.h
+++ libcxx/include/__format/buffer.h
@@ -101,10 +101,10 @@
 class _LIBCPP_TEMPLATE_VIS __internal_storage {
 public:
   _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; }
-  _LIBCPP_HIDE_FROM_ABI size_t capacity() { return __buffer_size_; }
 
-private:
   static constexpr size_t __buffer_size_ = 256 / sizeof(_CharT);
+
+private:
   _CharT __buffer_[__buffer_size_];
 };
 
@@ -223,10 +223,9 @@
                     __direct_storage<_CharT>, __internal_storage<_CharT>>;
 
 public:
-  _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
-      same_as<_Storage, __internal_storage<_CharT>>)
-      : __output_(__storage_.begin(), __storage_.capacity(), this),
-        __writer_(_VSTD::move(__out_it)) {}
+  _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
+    requires(same_as<_Storage, __internal_storage<_CharT>>)
+  : __output_(__storage_.begin(), __storage_.__buffer_size_, this), __writer_(_VSTD::move(__out_it)) {}
 
   _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
       same_as<_Storage, __direct_storage<_CharT>>)
@@ -270,7 +269,7 @@
 
 private:
   __internal_storage<_CharT> __storage_;
-  __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.capacity(), this};
+  __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size_, this};
   size_t __size_{0};
 };
 
@@ -292,7 +291,7 @@
 
 protected:
   __internal_storage<_CharT> __storage_;
-  __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.capacity(), this};
+  __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size_, this};
   typename __writer_selector<_OutIt, _CharT>::type __writer_;
 
   _Size __n_;
@@ -314,7 +313,7 @@
   _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
       : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) {
     if (__n <= 0) [[unlikely]]
-      __output_.reset(__storage_.begin(), __storage_.capacity());
+      __output_.reset(__storage_.begin(), __storage_.__buffer_size_);
   }
 
   _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
@@ -328,7 +327,7 @@
     // When the __n <= 0 the constructor already switched the buffers.
     if (__size_ == 0 && __ptr != __storage_.begin()) {
       __writer_.flush(__ptr, __size);
-      __output_.reset(__storage_.begin(), __storage_.capacity());
+      __output_.reset(__storage_.begin(), __storage_.__buffer_size_);
     }
 
     __size_ += __size;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125610.429464.patch
Type: text/x-patch
Size: 2668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220514/f81a8c0f/attachment-0001.bin>


More information about the libcxx-commits mailing list