From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74066 invoked by alias); 4 Mar 2015 09:27:30 -0000 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 Received: (qmail 74053 invoked by uid 89); 4 Mar 2015 09:27:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 Mar 2015 09:27:28 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t249RMmR023218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Mar 2015 04:27:22 -0500 Received: from blade.nx (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t249RLlI022487; Wed, 4 Mar 2015 04:27:22 -0500 Received: by blade.nx (Postfix, from userid 1000) id 0E2A1265054; Wed, 4 Mar 2015 09:27:20 +0000 (GMT) Date: Wed, 04 Mar 2015 09:27:00 -0000 From: Gary Benson To: Andreas Arnez Cc: Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [PATCH] New common function "startswith" Message-ID: <20150304092720.GA26337@blade.nx> References: <1425388224-8146-1-git-send-email-gbenson@redhat.com> <20150303160639.GB3243@adacore.com> <20150303171612.GA7569@blade.nx> <87y4nevsjg.fsf@br87z6lw.de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y4nevsjg.fsf@br87z6lw.de.ibm.com> X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00119.txt.bz2 Andreas Arnez wrote: > On Tue, Mar 03 2015, Gary Benson wrote: > > Joel Brobecker wrote: > > > Also, how about we rename the parameters to something like "str" > > > instead of "s1" and "pattern" for s2. It makes it faster, IMO, > > > to figure out the parameter order without having to read the > > > function's documentation, and therefore makes it's use a little > > > less error-prone. > > > > I can do that. I also found some more, with the pattern strncmp > > (string, "something", sizeof ("something") -1) so I'll update the > > patch to include those too. > > Considering the lot of occurrences, IMHO the function should better > be defined as inline. Then, if the compiler can inline strncmp, the > function calls will be eliminated completely. Also, this would > leave the string comparison visible to the compiler for > array-out-of-bound checks. For some reason I thought GDB didn't allow inline functions, but I see there are quite a few so, yeah, I'll do that. Aside from anything else it will allow the strlen calls to be eliminated for string constants. Cheers, Gary -- http://gbenson.net/