From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA] Use std::vector for moribund_locations
Date: Wed, 04 Jul 2018 04:51:00 -0000 [thread overview]
Message-ID: <cefea308-68e0-228d-c6b4-1fd9db52ce83@simark.ca> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2018-07-04 4:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 19:23 Tom Tromey
2018-07-03 14:46 ` Andrew Burgess
2018-07-04 4:51 ` Simon Marchi [this message]
2018-07-04 4:55 ` Tom Tromey
2018-07-04 17:39 ` Simon Marchi
2018-07-09 17:10 ` Tom Tromey
2018-07-11 1:21 ` Simon Marchi
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=cefea308-68e0-228d-c6b4-1fd9db52ce83@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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: link
Be 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