From 4b4f13f77e5db2ebf3202c8fdd68c5bcc685e4f9 Mon Sep 17 00:00:00 2001 From: mrabine Date: Sun, 15 Nov 2026 08:51:51 +0100 Subject: [PATCH 1/2] Fix atod performance regression --- dconv/include/dconv/atod.hpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/dconv/include/dconv/atod.hpp b/dconv/include/dconv/atod.hpp index 530b1f9..227d022 100644 --- a/dconv/include/dconv/atod.hpp +++ b/dconv/include/dconv/atod.hpp @@ -447,19 +447,6 @@ namespace dconv return Errc::Success; } - /** - * @brief parse again a number the fast path does not handle. - * @param probe probe to read from, positioned on the start of the number. - * @param value converted value. - * @param significand integer value when the error is NotDouble, first significant digits read otherwise. - * @param exponent decimal exponent read. - * @param negative sign read. - * @return Errc::Success on success, the error otherwise. - */ - template - DCONV_COLD Errc atodRewind (Probe& probe, double& value, uint64_t& significand, int64_t& exponent, - bool& negative); - /** * @brief string to double conversion that stops on integers. * @param probe probe to read from. @@ -537,8 +524,7 @@ namespace dconv } significand = u; } - else if (((Mode & AtodMode::ParseNanAndInf) != AtodMode::Json) && probe.getIfNoCase ('i') && - probe.getIfNoCase ('n') && probe.getIfNoCase ('f')) + else if (probe.getIfNoCase ('i') && probe.getIfNoCase ('n') && probe.getIfNoCase ('f')) { if (probe.getIfNoCase ('i')) { @@ -557,13 +543,20 @@ namespace dconv } value = negative ? -std::numeric_limits::infinity () : std::numeric_limits::infinity (); + if constexpr ((Mode & AtodMode::ParseNanAndInf) == AtodMode::Json) + { + return Errc::InvalidNumber; + } return Errc::Success; } - else if (((Mode & AtodMode::ParseNanAndInf) != AtodMode::Json) && probe.getIfNoCase ('n') && - probe.getIfNoCase ('a') && probe.getIfNoCase ('n')) + else if (probe.getIfNoCase ('n') && probe.getIfNoCase ('a') && probe.getIfNoCase ('n')) { value = negative ? -std::numeric_limits::quiet_NaN () : std::numeric_limits::quiet_NaN (); + if constexpr ((Mode & AtodMode::ParseNanAndInf) == AtodMode::Json) + { + return Errc::InvalidNumber; + } return Errc::Success; } else @@ -659,7 +652,7 @@ namespace dconv if constexpr (Rewind) { probe.seek (beg); - return atodRewind (probe, value, significand, exponent, negative); + return atod (probe, value, significand, exponent, negative); } else { @@ -667,13 +660,6 @@ namespace dconv } } - template - DCONV_COLD Errc atodRewind (Probe& probe, double& value, uint64_t& significand, int64_t& exponent, - bool& negative) - { - return atod (probe, value, significand, exponent, negative); - } - /** * @brief string to double conversion. * @param probe probe to read from. From 2387eca67ba84cccc793cf2f25f252815e9a04d8 Mon Sep 17 00:00:00 2001 From: mrabine Date: Sun, 15 Nov 2026 08:52:06 +0100 Subject: [PATCH 2/2] Bump version to 2.0.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 227cea2..38f77a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 +2.0.1