This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] New common function "startswith"


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]