public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthias Kretz <mkretz@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5820] Fix hash_map::traverse overload Date: Tue, 7 Dec 2021 12:15:03 +0000 (GMT) [thread overview] Message-ID: <20211207121503.08C813858C60@sourceware.org> (raw) https://gcc.gnu.org/g:c93e704b9e0411f1db031df9716b9958307590e3 commit r12-5820-gc93e704b9e0411f1db031df9716b9958307590e3 Author: Matthias Kretz <m.kretz@gsi.de> 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 <m.kretz@gsi.de> 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<typename Arg, bool (*f)(const typename Traits::key_type &, const Value &, Arg)> @@ -225,7 +226,8 @@ public: { for (typename hash_table<hash_entry>::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<typename Arg, bool (*f)(const typename Traits::key_type &, diff --git a/gcc/predict.c b/gcc/predict.c index 3cb4e3c0eb5..1a1da7e8360 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3044,7 +3044,7 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value, void *) { gcc_assert (!value); - return false; + return true; } /* Predict branch probabilities and estimate profile for basic block BB.
reply other threads:[~2021-12-07 12:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211207121503.08C813858C60@sourceware.org \ --to=mkretz@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).