This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb/linux-fork: simplify one_fork_p
- From: "Christian Biesinger via gdb-patches" <gdb-patches at sourceware dot org>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Sun, 19 Jan 2020 11:41:30 -0500
- Subject: Re: [PATCH] gdb/linux-fork: simplify one_fork_p
- References: <20200119161058.864-1-simon.marchi@polymtl.ca>
- Reply-to: Christian Biesinger <cbiesinger at google dot com>
On Sun, Jan 19, 2020 at 11:11 AM Simon Marchi <simon.marchi@polymtl.ca> wrote:
>
> Unless I'm missing something, this function is a complicated way of
> saying "fork_list.size () == 1".
Before C++11, size() wasn't guaranteed to run in constant time, so I
assume the code was written to handle that. But GDB uses C++11, so
this change seems fine.
https://en.cppreference.com/w/cpp/container/list/size
>
> gdb/ChangeLog:
>
> * linux-fork.c (one_fork_p): Simplify.
> ---
> gdb/linux-fork.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
> index 284f1985d0dc..357188685d07 100644
> --- a/gdb/linux-fork.c
> +++ b/gdb/linux-fork.c
> @@ -110,8 +110,7 @@ find_last_fork (void)
> static bool
> one_fork_p ()
> {
> - return (!fork_list.empty ()
> - && &fork_list.front () == &fork_list.back ());
> + return fork_list.size () == 1;
> }
>
> /* Add a new fork to the internal fork list. */
> --
> 2.24.1
>