[libcxx-commits] [PATCH] D110499: [libc++][format][5/6] Improve format_to_n.
Victor Zverovich via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 26 08:13:24 PST 2021
vitaut 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...))};
----------------
Mordante wrote:
> 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.
I understand that you need a check, my comment was that special casing 0 (and negative size) is probably not worth it. I'd suggest keeping it simpler and go through `__format_to_n_buffer` in all cases.
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