[libc-commits] [PATCH] D131301: [libc] add int to string for extended bases
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon Aug 8 00:18:14 PDT 2022
sivachandra added a comment.
Tests?
================
Comment at: libc/src/__support/integer_to_string.h:100
+ // other numbers. For this reason, it's better to use the default
+ // IntegerToString class if the base is known to be 10.
+
----------------
You can avoid this with `constexpr` arrangement like this:
```
private:
static constexpr size_t BUFSIZE_BASE10 = ...; // The current base 10 formula from IntegerToString
static constexpr size_t BUFSIZE_COMMON = ...; // The formula below
public:
static constexpr size_t BUFSIZE = Base == 10 ? BUFSIZE_BASE10 : BUFSIZE_COMMON;
```
================
Comment at: libc/src/__support/integer_to_string.h:123
+ if (conv_base < Base) {
+ return;
+ }
----------------
Silently return? Can we perhaps return a boolean value to indicate success/failure?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131301/new/
https://reviews.llvm.org/D131301
More information about the libc-commits
mailing list