This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Use std::vector for moribund_locations


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]