From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3751 invoked by alias); 21 Dec 2006 12:47:47 -0000 Received: (qmail 3692 invoked by uid 22791); 21 Dec 2006 12:47:46 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-vbr1.xs4all.nl (HELO smtp-vbr1.xs4all.nl) (194.109.24.21) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 21 Dec 2006 12:47:37 +0000 Received: from webmail.xs4all.nl (dovemail5.xs4all.nl [194.109.26.7]) by smtp-vbr1.xs4all.nl (8.13.8/8.13.8) with ESMTP id kBLCkUGI054315; Thu, 21 Dec 2006 13:46:34 +0100 (CET) (envelope-from mark.kettenis@xs4all.nl) Received: from 192.87.1.22 (SquirrelMail authenticated user sibelius) by webmail.xs4all.nl with HTTP; Thu, 21 Dec 2006 13:46:34 +0100 (CET) Message-ID: <25093.192.87.1.22.1166705194.squirrel@webmail.xs4all.nl> In-Reply-To: <20061221110904.GG3640@adacore.com> References: <458A3B6C.2040803@de.ibm.com> <20061221110904.GG3640@adacore.com> Date: Thu, 21 Dec 2006 12:47:00 -0000 Subject: Re: [RFA] gdbserver/server.c: Replace 2x strlen() by a variable From: "Mark Kettenis" To: "Joel Brobecker" Cc: "Markus Deuling" , "GDB Patches" User-Agent: SquirrelMail/1.4.8 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-12/txt/msg00287.txt.bz2 > > 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