Re: [PATCH] New common function "startswith"

Gary Benson
2015-03-04T09:27:30Z

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

--