[libcxx-commits] [PATCH] D110499: [libc++][format][5/6] Improve format_to_n.

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


Mordante marked an inline comment as done.
Mordante added inline comments.


================
Comment at: libcxx/include/format:606-608
+  if (__n <= 0) [[unlikely]]
+    return {_VSTD::move(__out_it),
+            iter_difference_t<_OutIt>(formatted_size(__fmt, __args...))};
----------------
vitaut wrote:
> Not sure if this branch is worth adding. `__format_to_n_buffer` should perform reasonably well for this case.
I need to guard against `__n < 0` since the `__n` is used as an unsigned capacity in the buffer code. So I thought it was easiest to add the guard here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110499



More information about the libcxx-commits mailing list