diff options
author | Patrick Palka <ppalka@redhat.com> | 2025-05-29 10:12:23 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2025-06-01 10:41:20 -0400 |
commit | 771fcb9fe9b3fce8336a797c03c399a63e11eb21 (patch) | |
tree | 1a68a8164a6a9fae5c5c23abe3a11f43c8099851 | |
parent | 48d6f5dbb0e412266ebb77def04ed378ca856029 (diff) | |
download | gcc-771fcb9fe9b3fce8336a797c03c399a63e11eb21.zip gcc-771fcb9fe9b3fce8336a797c03c399a63e11eb21.tar.gz gcc-771fcb9fe9b3fce8336a797c03c399a63e11eb21.tar.bz2 |
libstdc++: Compare keys and values separately in flat_map::operator==
Instead of effectively doing a zipped comparison of the keys and values,
compare them separately to leverage the underlying containers' optimized
equality implementations.
libstdc++-v3/ChangeLog:
* include/std/flat_map (_Flat_map_impl::operator==): Compare
keys and values separately.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit ad96f0344adfc847874b34b43f30371979ae9963)
-rw-r--r-- | libstdc++-v3/include/std/flat_map | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/flat_map b/libstdc++-v3/include/std/flat_map index cec7f36..4bd4963 100644 --- a/libstdc++-v3/include/std/flat_map +++ b/libstdc++-v3/include/std/flat_map @@ -873,7 +873,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION [[nodiscard]] friend bool operator==(const _Derived& __x, const _Derived& __y) - { return std::equal(__x.begin(), __x.end(), __y.begin(), __y.end()); } + { + return __x._M_cont.keys == __y._M_cont.keys + && __x._M_cont.values == __y._M_cont.values; + } template<typename _Up = value_type> [[nodiscard]] |