[libcxx-commits] [PATCH] D64341: [libcxx] speedup to_string for floating point numbers

Afanasyev Ivan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 8 07:49:58 PDT 2019


ivafanas created this revision.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne, christof.

Proposal to speedup `to_string / to_wstring` for floating points numbers by reducing `sprintf` calls and allocations using stack buffer.

Benchmark results:
http://quick-bench.com/vS-2RuYzsZrBNRbhsliN4o8M8B4

- `to_string` is improved in 1.3x times for small values (tested on zero)
- `to_wstring` is not changed for small values
- `to_string` is improved in 2.1x times for `-DBL_MAX`
- `to_wstring` is improved in 5.2x times for `-DBL_MAX`

Proposed implementation fallbacks to the previous one for some long double values and non-standard floats / doubles so conversion tests were added for `numeric_limits<T>::max / min / lowest`.


Repository:
  rCXX libc++

https://reviews.llvm.org/D64341

Files:
  libcxx/src/string.cpp
  libcxx/test/std/strings/string.conversions/to_string.pass.cpp
  libcxx/test/std/strings/string.conversions/to_wstring.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64341.208409.patch
Type: text/x-patch
Size: 6383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190708/29bb3267/attachment.bin>


More information about the libcxx-commits mailing list