Re: [PATCH] New common function "startswith"

Andreas Arnez
2015-03-03T18:34:52Z

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.