[libcxx-commits] [PATCH] D103339: [libcxx][NFC] Tidy up calculation of __nbuf in num_put::do_put, and add comments
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon May 31 23:12:19 PDT 2021
Mordante added inline comments.
================
Comment at: libcxx/include/locale:1466
+ + ((__iob.flags() & ios_base::showbase) != 0) // base prefix
+ + 1; // terminating null character
char __nar[__nbuf];
----------------
ldionne wrote:
> Mordante wrote:
> > Wouldn't it look better to do the rounded up character determination in one step?
> > `((numeric_limits<unsigned long>::digits + 2) / 3)`
> IMO it's easier to read as-is since the `+ 2` trick isn't immediately obvious (to me at least).
I thought this was very common idiom for rounding up. But if it's not obvious for everybody, then I'm in favour of keeping the code as is.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103339/new/
https://reviews.llvm.org/D103339
More information about the libcxx-commits
mailing list