Revert "Microsoft's floating-point to_chars powered by Ryu and Ryu Printf"
This reverts commit a8025e06fc0f2fe1bbee9e1a6f15c336bfbdcb05 since
it triggers PR52584 with debug info enabled.
NOKEYCHECK=True
GitOrigin-RevId: ae53d02f557cdec5f05a19239f887b06d1a8518d
diff --git a/src/charconv.cpp b/src/charconv.cpp
index 60ec3ec..533e59b 100644
--- a/src/charconv.cpp
+++ b/src/charconv.cpp
@@ -9,14 +9,27 @@
#include "charconv"
#include <string.h>
-#include "include/ryu/digit_table.h"
-#include "include/to_chars_floating_point.h"
-
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __itoa
{
+static constexpr char cDigitsLut[200] = {
+ '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0',
+ '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4',
+ '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2',
+ '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
+ '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3',
+ '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',
+ '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5',
+ '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
+ '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6',
+ '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4',
+ '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8',
+ '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
+ '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9',
+ '7', '9', '8', '9', '9'};
+
template <typename T>
inline _LIBCPP_INLINE_VISIBILITY char*
append1(char* buffer, T i) noexcept
@@ -29,7 +42,7 @@
inline _LIBCPP_INLINE_VISIBILITY char*
append2(char* buffer, T i) noexcept
{
- memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2);
+ memcpy(buffer, &cDigitsLut[(i)*2], 2);
return buffer + 2;
}
@@ -144,53 +157,4 @@
} // namespace __itoa
-// The original version of floating-point to_chars was written by Microsoft and
-// contributed with the following license.
-
-// Copyright (c) Microsoft Corporation.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// This implementation is dedicated to the memory of Mary and Thavatchai.
-
-to_chars_result to_chars(char* __first, char* __last, float __value) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
-}
-
-to_chars_result to_chars(char* __first, char* __last, double __value) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
-}
-
-to_chars_result to_chars(char* __first, char* __last, long double __value) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value),
- chars_format{}, 0);
-}
-
-to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
-}
-
-to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
-}
-
-to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value),
- __fmt, 0);
-}
-
-to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
- __precision);
-}
-
-to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
- __precision);
-}
-
-to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
- __first, __last, static_cast<double>(__value), __fmt, __precision);
-}
-
_LIBCPP_END_NAMESPACE_STD