RE: [PATCH] cobol: Replace quadratic loop removing std::set elements

2025-04-05 Thread Robert Dubner
> -Original Message- > From: Jonathan Wakely > Sent: Thursday, March 20, 2025 18:01 > To: James K. Lowden > Cc: gcc-patches@gcc.gnu.org; Robert Dubner > Subject: Re: [PATCH] cobol: Replace quadratic loop removing std::set > elements > > On Thu, 20 Mar 202

[PATCH] cobol: Replace quadratic loop removing std::set elements

2025-04-04 Thread Jonathan Wakely
There's no need to keep using std::find_if from the beginning of the container after every removal, just update the iterator after erasing an element. This is how C++20 std::erase_if is implemented. gcc/cobol/ChangeLog: * except.cc (cbl_enabled_exceptions_t::turn_on_off): Replace

Re: [PATCH] cobol: Replace quadratic loop removing std::set elements

2025-03-21 Thread James K. Lowden
On Thu, 20 Mar 2025 22:01:28 + Jonathan Wakely wrote: > > LGTM. I am gun-shy about using iterators while modifying > > containers. I know there are rules. :-/ > > Yes, the erased iterator is invalidated, but it returns an iterator to > the next element after the erased one, so we can conti

Re: [PATCH] cobol: Replace quadratic loop removing std::set elements

2025-03-20 Thread James K. Lowden
On Wed, 19 Mar 2025 20:33:36 + Jonathan Wakely wrote: > There's no need to keep using std::find_if from the beginning of the > container after every removal, just update the iterator after erasing > an element. > > This is how C++20 std::erase_if is implemented.\ LGTM. I am gun-shy about u

Re: [PATCH] cobol: Replace quadratic loop removing std::set elements

2025-03-20 Thread Jonathan Wakely
On Thu, 20 Mar 2025 at 21:27, James K. Lowden wrote: > > On Wed, 19 Mar 2025 20:33:36 + > Jonathan Wakely wrote: > > > There's no need to keep using std::find_if from the beginning of the > > container after every removal, just update the iterator after erasing > > an element. > > > > This is