This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Re: [RFA] gdbserver/server.c: Replace 2x strlen() by a variable


On Thu, Dec 21, 2006 at 05:05:17PM +0400, Joel Brobecker wrote:
> > 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 is correct, at least for recent versions of GCC.  strlen of a
constant string without embedded zeros is folded to sizeof the string
minus one.

> How about avoiding the string duplication? Do you object to that too?
> This change seems like a good idea to me - although I agree that the
> risks of inconsistency are very small...

If it makes the code harder to read, I do object.  This, and similar
motifs with hardcoded lengths instead of duplicated strlens, are all
through that file.  I was careful to keep the duplications close
together so that they are easily visually confirmed.  I don't want to
have to hunt around for the code implementing a particular packet.

If it makes the code easier to read somehow, I don't object - I'd
have to see it.

-- 
Daniel Jacobowitz
CodeSourcery


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