From af9768e7bd89735a26b936c86869e2bdb1651b21 Mon Sep 17 00:00:00 2001 From: iwabuchi Date: Sat, 30 Sep 2023 13:16:48 -0700 Subject: [PATCH] (JSON) Bugfix in general compare --- include/metall/json/details/perroht_object.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/metall/json/details/perroht_object.hpp b/include/metall/json/details/perroht_object.hpp index 3c9260ba..a68c073c 100644 --- a/include/metall/json/details/perroht_object.hpp +++ b/include/metall/json/details/perroht_object.hpp @@ -265,12 +265,15 @@ template inline bool general_perroht_object_equal( const perroht_object &object, const other_object_type &other_object) noexcept { - return object.size() == other_object.size() && - std::equal(object.begin(), object.end(), other_object.begin(), - other_object.end(), [](const auto &lhs, const auto &rhs) { - return lhs.key() == rhs.key() && - lhs.value() == rhs.value(); - }); + if (object.size() != other_object.size()) return false; + + for (const auto &key_value : object) { + // TODO: could be optimized + auto itr = other_object.find(key_value.key_c_str()); + + if (itr == other_object.end()) return false; + if (key_value.value() != itr->value()) return false; + } } } // namespace metall::json::jsndtl