From c93e704b9e0411f1db031df9716b9958307590e3 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Fri, 3 Dec 2021 09:37:52 +0100 Subject: [PATCH] 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. --- gcc/hash-map.h | 6 ++++-- gcc/predict.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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