gcc/libstdc++-v3/testsuite
Jonathan Wakely 51ec07b116 libstdc++: Optimize std::to_string using std::string::resize_and_overwrite
This uses std::string::__resize_and_overwrite to avoid initializing the
string buffer with characters that are immediately overwritten. This
results in about 6% better performance for the std_to_string case in
int-benchmark.cc from https://github.com/fmtlib/format-benchmark

This requires a change to a testcase. The previous implementation
guaranteed that the string returned from std::to_string(integral-type)
would have no excess capacity, because it was constructed with the
correct length. The new implementation constructs an empty string and
then resizes it with resize_and_overwrite, which over-allocates. This
means that the "no-excess capacity" guarantee no longer holds.

We can also greatly improve the performance of std::to_wstring by using
std::to_string and then widening it with a new helper function, instead
of using std::swprintf to do the formatting.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (to_string(integral-type)): Use
	resize_and_overwrite when available.
	(__to_wstring_numeric): New helper functions.
	(to_wstring): Use std::to_string then __to_wstring_numeric.
	* testsuite/21_strings/basic_string/numeric_conversions/char/to_string_int.cc:
	Remove check for no excess capacity.
2023-08-17 20:24:17 +01:00
..
17_intro libstdc++: Fix some AIX test failures 2023-04-12 23:25:17 +01:00
18_support libstdc++: Fix some tests that fail with -fno-exceptions 2023-06-07 16:51:59 +01:00
19_diagnostics libstdc++: Fix some AIX test failures 2023-04-12 23:25:17 +01:00
20_util libstdc++: Implement C++20 std::chrono::parse [PR104167] 2023-08-11 19:58:06 +01:00
21_strings libstdc++: Optimize std::to_string using std::string::resize_and_overwrite 2023-08-17 20:24:17 +01:00
22_locale libstdc++: Remove test dependency on _GLIBCXX_USE_C99_STDINT_TR1 2023-05-12 14:40:39 +01:00
23_containers libstdc++: Replace all manual FTM definitions and use 2023-08-16 15:16:25 +02:00
24_iterators libstdc++: Disable PCH for tests that rely on include order 2023-08-17 08:42:45 +01:00
25_algorithms libstdc++: Fix comment naming upstream PSTL test file 2023-08-16 17:23:35 +01:00
26_numerics c++: Improve location information in constant evaluation 2023-07-25 21:45:10 -04:00
27_io libstdc++: Check conversion from filesystem::path to wide strings [PR95048] 2023-07-12 21:04:13 +01:00
28_regex libstdc++: Define std::sub_match::swap member function (LWG 3204) 2023-04-05 11:37:19 +01:00
29_atomics libstdc++: Stop using _GLIBCXX_USE_C99_STDINT_TR1 in <cstdint> 2023-05-16 09:59:19 +01:00
30_threads libstdc++: Avoid -Wmaybe-uninitialized warning in std::stop_source [PR109339] 2023-03-31 14:20:52 +01:00
abi Update copyright years. 2023-01-16 11:52:17 +01:00
backward Update copyright years. 2023-01-16 11:52:17 +01:00
config Update copyright years. 2023-01-16 11:52:17 +01:00
data
decimal Update copyright years. 2023-01-16 11:52:17 +01:00
experimental libstdc++: Check conversion from filesystem::path to wide strings [PR95048] 2023-07-12 21:04:13 +01:00
ext libstdc++: Fix some tests that fail with -fno-exceptions 2023-06-07 16:51:59 +01:00
lib libstdc++: Fix testsuite no_pch directive 2023-08-17 08:42:45 +01:00
libstdc++-abi Update copyright years. 2023-01-16 11:52:17 +01:00
libstdc++-dg Update copyright years. 2023-01-16 11:52:17 +01:00
libstdc++-prettyprinters libstdc++: Handle invalid values in std::chrono pretty printers 2023-08-11 14:33:01 +01:00
libstdc++-xmethods libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064] 2023-03-10 11:10:23 +00:00
performance Update copyright years. 2023-01-16 11:52:17 +01:00
special_functions Update copyright years. 2023-01-16 11:52:17 +01:00
std libstdc++: Implement P2770R0 changes to join_view / join_with_view 2023-08-17 12:56:32 -04:00
tr1 Update copyright years. 2023-01-16 11:52:17 +01:00
tr2 Update copyright years. 2023-01-16 11:52:17 +01:00
util libstdc++: Synchronize PSTL with upstream 2023-06-26 11:34:43 -07:00
Makefile.am Update copyright years. 2023-01-16 11:52:17 +01:00
Makefile.in libstdc++: Don't use gstdint.h anymore 2022-10-29 00:55:42 +01:00