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

Afanasyev Ivan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 20 11:58:19 PDT 2019


ivafanas added a comment.

In D59178#1436754 <https://reviews.llvm.org/D59178#1436754>, @mclow.lists wrote:

> Now that revision 356585 has landed,  we can use `std::to_chars` to implement `to_string`
>
> I would suggest something like (untested code):
>
>   template <class T>
>   string __to_chars(T t)
>   {
>   char buf[numeric_limits<T>::digits10() + 3]; // +1 for '-' +1 for nul, and +1 for extra
>   to_chars_result res(buf, buf + sizeof(buf), t, 10);
>   return string(buf, res.ptr);
>   }
>   
>
> and then call *that* from the various `to_string` implementations.


Good.
I will try to implement this idea and test it for performance.


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

https://reviews.llvm.org/D59178





More information about the libcxx-commits mailing list