From: Patrick Palka Date: Thu, 29 May 2025 14:12:23 +0000 (-0400) Subject: libstdc++: Compare keys and values separately in flat_map::operator== X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad96f0344adfc847874b34b43f30371979ae9963;p=thirdparty%2Fgcc.git 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 --- diff --git a/libstdc++-v3/include/std/flat_map b/libstdc++-v3/include/std/flat_map index cec7f36cff9..4bd4963c2ad 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 [[nodiscard]]