This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] gdbserver/server.c: Replace 2x strlen() by a variable
- From: "Mark Kettenis" <mark dot kettenis at xs4all dot nl>
- To: "Joel Brobecker" <brobecker at adacore dot com>
- Cc: "Markus Deuling" <deuling at de dot ibm dot com>, "GDB Patches" <gdb-patches at sourceware dot org>
- Date: Thu, 21 Dec 2006 13:46:34 +0100 (CET)
- Subject: Re: [RFA] gdbserver/server.c: Replace 2x strlen() by a variable
- References: <458A3B6C.2040803@de.ibm.com> <20061221110904.GG3640@adacore.com>
> > ChangeLog:
> >
> > * server.c (handle_general_set): New variable len instead
> > of using strlen two times.
>
> Actually, since the same string is duplicated a couple of times,
> I would also suggest declaring a constant string "QPassSignals:"
> and use the constant instead of risking a typo... How about:
>
> const char str[] = "QPassSignals:";
>
> and then use "sizeof (str) - 1". Is that bad coding style? Otherwise,
> you can declare your sale constant:
>
> const int len = strlen (str);
>
> I am not reviewer, so these are just suggestions, not a request (JIC).
I'm pretty sure GCC will optimize away the strlen("QPassSignals:") anyway,
so we really shouldn't try to obfuscate the code just to make it a bit
faster. So if optimization was the Markus' argument for making this
change I object to this change.
Mark