From: Matthias Kretz Date: Fri, 3 Dec 2021 08:37:52 +0000 (+0100) Subject: Fix hash_map::traverse overload X-Git-Tag: basepoints/gcc-13~2493 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c93e704b9e0411f1db031df9716b9958307590e3;p=thirdparty%2Fgcc.git Fix hash_map::traverse overload The hash_map::traverse overload taking a non-const Value pointer breaks if the callback returns false. The other overload should behave the same. Signed-off-by: Matthias Kretz gcc/ChangeLog: * hash-map.h (hash_map::traverse): Let both overloads behave the same. * predict.c (assert_is_empty): Return true, thus not changing behavior. --- diff --git a/gcc/hash-map.h b/gcc/hash-map.h index dd039f103435..c4fe26cf5d10 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -217,7 +217,8 @@ public: } /* Call the call back on each pair of key and value with the passed in - arg. */ + arg until either the call back returns false or all pairs have been seen. + The traversal is unordered. */ template @@ -225,7 +226,8 @@ public: { for (typename hash_table::iterator iter = m_table.begin (); iter != m_table.end (); ++iter) - f ((*iter).m_key, (*iter).m_value, a); + if (!f ((*iter).m_key, (*iter).m_value, a)) + break; } template