[libcxx-commits] [PATCH] D97705: [RFC][libc++] Improve std::to_chars for base != 10.
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 14 13:53:38 PDT 2021
ldionne added a comment.
I think it would make sense to have a general implementation that works for all bases, and then have a few common bases (likely 2, 8, 10, 16 as you say) be compiled in the library. I think the top-level could look something like:
if (base == 2) // then dispatch to the implementation for base 2 in the library
else if (base == 8) // dispatch to base 8
else if (base == 10) // dispatch to base 10
else if (base == 16) // dispatch to base 16
else // general implementation
I'm not saying use `if` over `switch` or whatever -- I'm just saying IMO it would make sense to check for the base, optimize for a few common bases (for a modest increase in code size in the dylib), and then fallback to a general implementation available as templates that will be compiled in the user's binaries. WDYT?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97705/new/
https://reviews.llvm.org/D97705
More information about the libcxx-commits
mailing list