This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Use std::vector for moribund_locations
- From: Simon Marchi <simark at simark dot ca>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Wed, 4 Jul 2018 00:51:38 -0400
- Subject: Re: [RFA] Use std::vector for moribund_locations
- References: <20180605192346.5509-1-tom@tromey.com>
On 2018-06-05 03:23 PM, Tom Tromey wrote:
> @@ -12112,16 +12104,18 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
> void
> breakpoint_retire_moribund (void)
> {
> - struct bp_location *loc;
> - int ix;
> -
> - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
> - if (--(loc->events_till_retirement) == 0)
> - {
> - decref_bp_location (&loc);
> - VEC_unordered_remove (bp_location_p, moribund_locations, ix);
> - --ix;
> - }
> + auto it = std::remove_if (moribund_locations.begin (),
> + moribund_locations.end (),
> + [] (bp_location *loc)
> + {
> + if (--(loc->events_till_retirement) == 0)
> + {
> + decref_bp_location (&loc);
> + return true;
> + }
> + return false;
> + });
> + moribund_locations.erase (it, moribund_locations.end ());
> }
Just a note that this changes an "unordered remove" to an "ordered remove".
If we don't need to keep the relative order of the remaining elements, it
might be good performance-wise to keep the original behavior. This could
be done by keeping the original code structure (iterating by index) and
calling undordered_remove.
Simon