From 10d18792bd9bde83ab36b3be05affc30078b292b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 10 Jul 2026 13:00:37 +0200 Subject: [PATCH] Simplify number_float hash case: reuse existing type tag The number_float case introduced a redundant numeric_type local that duplicated the already-computed type variable (both equal value_t::number_float within that case). Removed per review feedback. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/hash.hpp | 3 +-- single_include/nlohmann/json.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp index 9df26dcb8..5e3f9ef02 100644 --- a/include/nlohmann/detail/hash.hpp +++ b/include/nlohmann/detail/hash.hpp @@ -188,8 +188,7 @@ std::size_t hash(const BasicJsonType& j) case BasicJsonType::value_t::number_float: { const auto h = std::hash {}(j.template get()); - const auto numeric_type = static_cast(BasicJsonType::value_t::number_float); - return combine(numeric_type, h); + return combine(type, h); } case BasicJsonType::value_t::binary: diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4b233ed5c..438973ef4 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6856,8 +6856,7 @@ std::size_t hash(const BasicJsonType& j) case BasicJsonType::value_t::number_float: { const auto h = std::hash {}(j.template get()); - const auto numeric_type = static_cast(BasicJsonType::value_t::number_float); - return combine(numeric_type, h); + return combine(type, h); } case BasicJsonType::value_t::binary: