Skip to content

Commit

Permalink
(JSON) Bugfix in general compare
Browse files Browse the repository at this point in the history
  • Loading branch information
KIwabuchi committed Sep 30, 2023
1 parent baa4fa8 commit af9768e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions include/metall/json/details/perroht_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,15 @@ template <typename allocator_type, typename other_object_type>
inline bool general_perroht_object_equal(
const perroht_object<allocator_type> &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
Expand Down

0 comments on commit af9768e

Please sign in to comment.