From: Kevin Buettner <kevinb@cygnus.com>
To: Andrew Cagney <ac131313@cygnus.com>,
GDB Patches <gdb-patches@sourceware.cygnus.com>
Subject: Re: [RFC] Notes on QUIT and STREQ et.al.
Date: Mon, 13 Mar 2000 08:28:00 -0000 [thread overview]
Message-ID: <1000313162754.ZM28984@ocotillo.lan> (raw)
In-Reply-To: <38CCC819.1071F28E@cygnus.com>
On Mar 13, 9:51pm, Andrew Cagney wrote:
> The attatched spells out the long term prospects of both STREQ et.al.
> and QUIT.
> Look OK to everyone?
[...]
> /* Gdb does *lots* of string compares. Use macros to speed them up by
> avoiding function calls if the first characters are not the same. */
>
> + /* NOTE: cagney/2000-03-13: There is no reason for using these macros
> + in new code (which is just short of marking them as deprecated).
> + While old code can continue to refer to them, new code is better
> + off using the more familar strcmp(). */
> +
> #define STRCMP(a,b) (*(a) == *(b) ? strcmp ((a), (b)) : (int)*(a) - (int)*(b))
> #define STREQ(a,b) (*(a) == *(b) ? !strcmp ((a), (b)) : 0)
> #define STREQN(a,b,c) (*(a) == *(b) ? !strncmp ((a), (b), (c)) : 0)
I haven't looked to see how often (or where) STREQ and STRCMP are
used, but these macros compare the first characters inline in an
attempt to improve performance. Have you assessed the benefits of
doing this? (If these optimizations significantly improve
performance, I think they should stay.)
It seems to me that a decent STREQ macro should also test to see
if the pointers are equal. I.e,
#define STREQ(a,b) ((a == b) || (*(a) == *(b) ? !strcmp ((a), (b)) : 0))
Kevin
From dan@cgsoftware.com Mon Mar 13 08:52:00 2000
From: Daniel Berlin <dan@cgsoftware.com>
To: Kevin Buettner <kevinb@cygnus.com>
Cc: Andrew Cagney <ac131313@cygnus.com>, GDB Patches <gdb-patches@sourceware.cygnus.com>
Subject: Re: [RFC] Notes on QUIT and STREQ et.al.
Date: Mon, 13 Mar 2000 08:52:00 -0000
Message-id: <Pine.LNX.4.10.10003130829420.6968-100000@localhost.localdomain>
References: <1000313162754.ZM28984@ocotillo.lan>
X-SW-Source: 2000-03/msg00231.html
Content-length: 631
>
> I haven't looked to see how often (or where) STREQ and STRCMP are
> used, but these macros compare the first characters inline in an
> attempt to improve performance. Have you assessed the benefits of
> doing this? (If these optimizations significantly improve
> performance, I think they should stay.)
I'll check out the performance.
I know GCC has a strlen expander, but no strcmp expander, so it might be a
benefit.
>
> It seems to me that a decent STREQ macro should also test to see
> if the pointers are equal. I.e,
>
> #define STREQ(a,b) ((a == b) || (*(a) == *(b) ? !strcmp ((a), (b)) : 0))
>
> Kevin
>
next parent reply other threads:[~2000-03-13 8:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <38CCC819.1071F28E@cygnus.com>
2000-03-13 8:28 ` Kevin Buettner [this message]
2000-03-13 11:50 ` J.T. Conklin
2000-04-01 0:00 ` Andrew Cagney
[not found] ` <5m1z5emy7b.fsf@jtc.redbacknetworks.com>
2000-04-01 0:00 ` Andrew Cagney
[not found] <200003131412.PAA16094@landau.wins.uva.nl>
2000-03-13 9:15 ` Jim Kingdon
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=1000313162754.ZM28984@ocotillo.lan \
--to=kevinb@cygnus.com \
--cc=ac131313@cygnus.com \
--cc=gdb-patches@sourceware.cygnus.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