mirror of https://github.com/godotengine/godot
Merge pull request #113982 from akien-mga/grisu2-2025-11
grisu2: Rediff patch and sync with latest upstream commit
This commit is contained in:
commit
14d8c55cfa
|
|
@ -437,7 +437,7 @@ Files extracted from upstream source:
|
|||
## grisu2
|
||||
|
||||
- Upstream: https://github.com/simdjson/simdjson/blob/master/src/to_chars.cpp
|
||||
- Version: git (4f4e81668ecb9d4d37fd5f59a1556d492507421d, 2023)
|
||||
- Version: git (667d0ed3c77f55cbda2082b034168d69898d1f88, 2025)
|
||||
- License: Apache and MIT
|
||||
|
||||
Files extracted from upstream source:
|
||||
|
|
|
|||
|
|
@ -809,20 +809,14 @@ void grisu2_wrap(char *buf, int &len, int &decimal_exponent, FloatType value) {
|
|||
*/
|
||||
inline char *append_exponent(char *buf, int e) {
|
||||
|
||||
if (e < 0) {
|
||||
e = -e;
|
||||
*buf++ = '-';
|
||||
} else {
|
||||
*buf++ = '+';
|
||||
}
|
||||
bool isNegative = e < 0;
|
||||
e = isNegative ? -e : e;
|
||||
*buf++ = isNegative ? '-' : '+';
|
||||
|
||||
auto k = static_cast<std::uint32_t>(e);
|
||||
if (k < 10) {
|
||||
if (k < 100) {
|
||||
// Always print at least two digits in the exponent.
|
||||
// This is for compatibility with printf("%g").
|
||||
*buf++ = '0';
|
||||
*buf++ = static_cast<char>('0' + k);
|
||||
} else if (k < 100) {
|
||||
*buf++ = static_cast<char>('0' + k / 10);
|
||||
k %= 10;
|
||||
*buf++ = static_cast<char>('0' + k);
|
||||
|
|
@ -915,6 +909,7 @@ char *to_chars(char *first, FloatType value) {
|
|||
value = -value;
|
||||
*first++ = '-';
|
||||
}
|
||||
|
||||
if (value == 0) // +-0
|
||||
{
|
||||
*first++ = '0';
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
diff --git a/thirdparty/grisu2/grisu2.h b/thirdparty/grisu2/grisu2.h
|
||||
index 19886cce47f..dbc09755fad 100644
|
||||
index f140e1a192..316a727ce0 100644
|
||||
--- a/thirdparty/grisu2/grisu2.h
|
||||
+++ b/thirdparty/grisu2/grisu2.h
|
||||
@@ -1,15 +1,12 @@
|
||||
@@ -1,15 +1,11 @@
|
||||
-#ifndef SIMDJSON_SRC_TO_CHARS_CPP
|
||||
-#define SIMDJSON_SRC_TO_CHARS_CPP
|
||||
-
|
||||
|
|
@ -20,7 +20,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
/*!
|
||||
implements the Grisu2 algorithm for binary to decimal floating-point
|
||||
conversion.
|
||||
@@ -26,7 +23,6 @@ PLDI 2010 [2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and
|
||||
@@ -26,7 +22,6 @@ PLDI 2010 [2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and
|
||||
Accurately", Proceedings of the ACM SIGPLAN 1996 Conference on Programming
|
||||
Language Design and Implementation, PLDI 1996
|
||||
*/
|
||||
|
|
@ -28,7 +28,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
|
||||
template <typename Target, typename Source>
|
||||
Target reinterpret_bits(const Source source) {
|
||||
@@ -718,7 +714,7 @@ v = buf * 10^decimal_exponent
|
||||
@@ -718,7 +713,7 @@ v = buf * 10^decimal_exponent
|
||||
len is the length of the buffer (number of decimal digits)
|
||||
The buffer must be large enough, i.e. >= max_digits10.
|
||||
*/
|
||||
|
|
@ -37,7 +37,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
diyfp v, diyfp m_plus) {
|
||||
|
||||
// --------(-----------------------+-----------------------)-------- (A)
|
||||
@@ -775,7 +771,7 @@ len is the length of the buffer (number of decimal digits)
|
||||
@@ -775,7 +770,7 @@ len is the length of the buffer (number of decimal digits)
|
||||
The buffer must be large enough, i.e. >= max_digits10.
|
||||
*/
|
||||
template <typename FloatType>
|
||||
|
|
@ -46,7 +46,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
|
||||
"internal error: not enough precision");
|
||||
|
||||
@@ -804,7 +800,7 @@ void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value) {
|
||||
@@ -804,7 +799,7 @@ void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value) {
|
||||
const boundaries w = compute_boundaries(value);
|
||||
#endif
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
}
|
||||
|
||||
/*!
|
||||
@@ -864,10 +860,7 @@ inline char *format_buffer(char *buf, int len, int decimal_exponent,
|
||||
@@ -858,10 +853,7 @@ inline char *format_buffer(char *buf, int len, int decimal_exponent,
|
||||
// len <= max_exp + 2
|
||||
|
||||
std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
|
||||
|
|
@ -67,7 +67,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
}
|
||||
|
||||
if (0 < n && n <= max_exp) {
|
||||
@@ -909,8 +902,6 @@ inline char *format_buffer(char *buf, int len, int decimal_exponent,
|
||||
@@ -903,8 +895,6 @@ inline char *format_buffer(char *buf, int len, int decimal_exponent,
|
||||
return append_exponent(buf, n - 1);
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
/*!
|
||||
The format of the resulting decimal representation is similar to printf's %g
|
||||
format. Returns an iterator pointing past-the-end of the decimal representation.
|
||||
@@ -918,19 +909,15 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
|
||||
@@ -912,8 +902,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
|
||||
@note The buffer must be large enough.
|
||||
@note The result is NOT null-terminated.
|
||||
*/
|
||||
|
|
@ -87,9 +87,8 @@ index 19886cce47f..dbc09755fad 100644
|
|||
bool negative = std::signbit(value);
|
||||
if (negative) {
|
||||
value = -value;
|
||||
*first++ = '-';
|
||||
}
|
||||
-
|
||||
@@ -922,9 +912,6 @@ char *to_chars(char *first, const char *last, double value) {
|
||||
|
||||
if (value == 0) // +-0
|
||||
{
|
||||
- *first++ = '0';
|
||||
|
|
@ -98,7 +97,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
*first++ = '0';
|
||||
return first;
|
||||
}
|
||||
@@ -940,15 +927,13 @@ char *to_chars(char *first, const char *last, double value) {
|
||||
@@ -934,15 +921,11 @@ char *to_chars(char *first, const char *last, double value) {
|
||||
// len is the length of the buffer, i.e. the number of decimal digits.
|
||||
int len = 0;
|
||||
int decimal_exponent = 0;
|
||||
|
|
@ -114,6 +113,7 @@ index 19886cce47f..dbc09755fad 100644
|
|||
}
|
||||
-} // namespace internal
|
||||
-} // namespace simdjson
|
||||
+} // namespace grisu2
|
||||
|
||||
-
|
||||
-#endif // SIMDJSON_SRC_TO_CHARS_CPP
|
||||
\ No newline at end of file
|
||||
+} // namespace grisu2
|
||||
|
|
|
|||
Loading…
Reference in New Issue