From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7857) id 08C813858C60; Tue, 7 Dec 2021 12:15:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08C813858C60 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Matthias Kretz To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5820] Fix hash_map::traverse overload X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: ba6bb287f03d42ab6c4f39ce99dcf94ec5113655 X-Git-Newrev: c93e704b9e0411f1db031df9716b9958307590e3 Message-Id: <20211207121503.08C813858C60@sourceware.org> Date: Tue, 7 Dec 2021 12:15:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2021 12:15:03 -0000 https://gcc.gnu.org/g:c93e704b9e0411f1db031df9716b9958307590e3 commit r12-5820-gc93e704b9e0411f1db031df9716b9958307590e3 Author: Matthias Kretz Date: Fri Dec 3 09:37:52 2021 +0100 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: --- 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 dd039f10343..c4fe26cf5d1 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