[libc] Simplify decimalStringToFloat and hexadecimalStringToFloat and improve their...
authorTue Ly <lntue@google.com>
Thu, 11 Nov 2021 16:22:52 +0000 (11:22 -0500)
committerTue Ly <lntue@google.com>
Thu, 11 Nov 2021 23:33:24 +0000 (18:33 -0500)
commit499ca806dcfb5f5c842fb240e150140fb15011ed
treea8d03c7eefef161d0a8b38d17220cecf53a11170
parent98f80d248d9c888c2219454c1f655bc324b80cdc
[libc] Simplify decimalStringToFloat and hexadecimalStringToFloat and improve their performance.

Combine two loops in decimalStringToFloat and hexadecimalStringToFloat that extract the digits and re-arrange them a little bit.  This slightly improves the performance of strtof and strtod:
Running libc_str_to_float_comparison_test parse-number-fxx-test_data/data/* on my machine (Ryzen 1700)
- with glibc: ~1.92 seconds
- with current implementation: ~1.78 seconds
- with this change: ~1.67 seconds

Differential Revision: https://reviews.llvm.org/D113681
libc/src/__support/str_to_float.h