From fc1df0b7db4e9d2541138a7f3f0c14749d5d0af0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 23 Jun 2026 13:14:56 +0200 Subject: [PATCH] :recycle: remove unnecessary if (#5172) Signed-off-by: Niels Lohmann --- include/nlohmann/detail/conversions/to_json.hpp | 5 +---- single_include/nlohmann/json.hpp | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 0e0fb4655..aef1b1a25 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -214,10 +214,7 @@ struct external_constructor j.m_data.m_type = value_t::array; j.m_data.m_value = value_t::array; j.m_data.m_value.array->resize(arr.size()); - if (arr.size() > 0) - { - std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); - } + std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); j.set_parents(); j.assert_invariant(); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index dec481118..2facfbdf8 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6220,10 +6220,7 @@ struct external_constructor j.m_data.m_type = value_t::array; j.m_data.m_value = value_t::array; j.m_data.m_value.array->resize(arr.size()); - if (arr.size() > 0) - { - std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); - } + std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); j.set_parents(); j.assert_invariant(); }