[libcxx-commits] [PATCH] D59178: [libc++] Speedup to_string and to_wstring for integers using stack buffer and SSO

Roman Lebedev via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 10 10:59:37 PDT 2019


lebedev.ri added a comment.

In D59178#1423778 <https://reviews.llvm.org/D59178#1423778>, @ivafanas wrote:

> Code correctness was checked via
>
>   make llvm-check
>


I don't think `llvm-check` build target exists. Did you mean `check-llvm`?
Even then, it will only check LLVM, not libc++; you'd want `check-libcxx` or `check-all`.

> Please, let me know if this command doesn't do what is expected according to documentation (I'm newby in clang project).



================
Comment at: libcxx/src/string.cpp:356-357
+{
+    constexpr size_t size = 4 * sizeof(V) + 1; // +1 for null char from swprintf
+    typename S::value_type buf[size] = {};
+    const int len = sprintf_like(buf, size, fmt, a);
----------------
`initial_string` should preallocate sufficiently-long string already.
If it does not, it should be fixed, no?



================
Comment at: libcxx/src/string.cpp:358-359
+    typename S::value_type buf[size] = {};
+    const int len = sprintf_like(buf, size, fmt, a);
+    return S(buf, buf + len);
+}
----------------
Missing error checking.
```
RETURN VALUE
       Upon successful return, these functions return the number of characters printed (excluding the null byte used to end output to strings).

```


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D59178





More information about the libcxx-commits mailing list