This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] New common function "startswith"
- From: Gary Benson <gbenson at redhat dot com>
- To: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- Cc: Joel Brobecker <brobecker at adacore dot com>, gdb-patches at sourceware dot org
- Date: Wed, 4 Mar 2015 09:27:20 +0000
- Subject: Re: [PATCH] New common function "startswith"
- Authentication-results: sourceware.org; auth=none
- References: <1425388224-8146-1-git-send-email-gbenson at redhat dot com> <20150303160639 dot GB3243 at adacore dot com> <20150303171612 dot GA7569 at blade dot nx> <87y4nevsjg dot fsf at br87z6lw dot de dot ibm dot com>
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/