From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125632 invoked by alias); 3 Mar 2015 18:34:52 -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 125622 invoked by uid 89); 3 Mar 2015 18:34:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp12.uk.ibm.com Received: from e06smtp12.uk.ibm.com (HELO e06smtp12.uk.ibm.com) (195.75.94.108) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 03 Mar 2015 18:34:51 +0000 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Mar 2015 18:34:48 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 3 Mar 2015 18:34:45 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 926B417D8059 for ; Tue, 3 Mar 2015 18:35:03 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t23IYi3s9634290 for ; Tue, 3 Mar 2015 18:34:44 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t23IYiRe018889 for ; Tue, 3 Mar 2015 11:34:44 -0700 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-115.boeblingen.de.ibm.com [9.152.212.115]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t23IYhcQ018880; Tue, 3 Mar 2015 11:34:43 -0700 From: Andreas Arnez To: Gary Benson Cc: Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [PATCH] New common function "startswith" References: <1425388224-8146-1-git-send-email-gbenson@redhat.com> <20150303160639.GB3243@adacore.com> <20150303171612.GA7569@blade.nx> Date: Tue, 03 Mar 2015 18:34:00 -0000 In-Reply-To: <20150303171612.GA7569@blade.nx> (Gary Benson's message of "Tue, 3 Mar 2015 17:16:12 +0000") Message-ID: <87y4nevsjg.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15030318-0009-0000-0000-00000353839D X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00109.txt.bz2 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.