The function num_get<_CharT>::stage2_int_prep makes unnecessary copy of src into atoms when char_type is char. This can be avoided by creating
a switch on type and just returning __src when char_type is char. Running a synthetic benchmark shows the impact of this change:
The test case can be found here: https://github.com/hiraditya/std-benchmark/blob/master/cxx/stringstream.bench.cpp
Without the change with llvm-project/trunk
$ export LD_LIBRARY_PATH=/work/llvm-project/install/lib; ./cxx/stringstream.bench.cpp.out Run on (24 X 1200 MHz CPU s) 2017-02-22 14:37:34 Benchmark Time CPU Iterations -------------------------------------------------------------- BM_Istream_numbers/32 8328 ns 8336 ns 83121 BM_Istream_numbers/64 8312 ns 8320 ns 83754 BM_Istream_numbers/128 8301 ns 8309 ns 83975 BM_Istream_numbers/256 8298 ns 8306 ns 84349 BM_Istream_numbers/512 8303 ns 8311 ns 84308 BM_Istream_numbers/1024 8301 ns 8309 ns 84316
With the change on llvm-project/trunk
$ export LD_LIBRARY_PATH=/work/llvm-project/install-sstream/lib; ./cxx/stringstream.bench.cpp.out Run on (24 X 1200 MHz CPU s) 2017-02-22 14:37:55 Benchmark Time CPU Iterations -------------------------------------------------------------- BM_Istream_numbers/32 7465 ns 7472 ns 91957 BM_Istream_numbers/64 7460 ns 7467 ns 93824 BM_Istream_numbers/128 7457 ns 7464 ns 93875 BM_Istream_numbers/256 7456 ns 7463 ns 93781 BM_Istream_numbers/512 7455 ns 7462 ns 93793 BM_Istream_numbers/1024 7457 ns 7464 ns 93757