This is the mail archive of the 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]

Re: [RFC] Notes on QUIT and STREQ

On Mar 13,  9:51pm, Andrew Cagney wrote:

> The attatched spells out the long term prospects of both STREQ
> 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))


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