From: Simon Marchi <simon.marchi@ericsson.com>
To: Tom Tromey <tom@tromey.com>, <gdb-patches@sourceware.org>
Subject: Re: [RFA] Remove a VEC from type.c
Date: Tue, 29 May 2018 15:58:00 -0000 [thread overview]
Message-ID: <b7a0bd60-5996-334a-25d5-1228489a7fb0@ericsson.com> (raw)
In-Reply-To: <20180529151002.5700-1-tom@tromey.com>
On 2018-05-29 11:10 AM, Tom Tromey wrote:
> This removes a VEC from type.c, by using std::vector.
>
> While doing this I also took the opportunity to change
> types_deeply_equal to return bool. This caught some weird code in
> typy_richcompare, now fixed.
>
> And, since I was changing types_deeply_equal, it seemed like a good
> idea to also change types_equal, so this patch includes that as well.
>
> Tested by the buildbot.
LGTM, I just noted some nits.
> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
> index 4f77a5214e3..2be0d2e97d9 100644
> --- a/gdb/gdbtypes.c
> +++ b/gdb/gdbtypes.c
> @@ -3551,10 +3551,10 @@ integer_types_same_name_p (const char *first, const char *second)
> return 1;
> }
>
> -/* Compares type A to type B returns 1 if the represent the same type
> - 0 otherwise. */
> +/* Compares type A to type B returns true if the represent the same
> + type, false otherwise. */
Could you fix the "the" -> "they" typo at the same time? It wouldn't hurt to
improve the syntax as well, it reads a bit weird.
> -/* A helper function to compare two strings. Returns 1 if they are
> - the same, 0 otherwise. Handles NULLs properly. */
> +/* A helper function to compare two strings. Returns true if they are
> + the same, false otherwise. Handles NULLs properly. */
>
> -static int
> +static bool
> compare_maybe_null_strings (const char *s, const char *t)
> {
> if (s == NULL && t != NULL)
> - return 0;
> + return false;
> else if (s != NULL && t == NULL)
> - return 0;
> + return false;
> else if (s == NULL && t== NULL)
> - return 1;
> + return true;
> return strcmp (s, t) == 0;
> }
Not really related to your patch, but I think we could reduce the number of
required comparisons/arithmetic operations by doing
if (s == NULL || t == NULL)
return s == t;
return strcmp (s, t) == 0;
Simon
next prev parent reply other threads:[~2018-05-29 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 15:13 Tom Tromey
2018-05-29 15:58 ` Simon Marchi [this message]
2018-05-29 17:58 ` Tom Tromey
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=b7a0bd60-5996-334a-25d5-1228489a7fb0@ericsson.com \
--to=simon.marchi@ericsson.com \
--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