This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH] New common function "startswith"
- From: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- To: Gary Benson <gbenson at redhat dot com>
- Cc: Joel Brobecker <brobecker at adacore dot com>, gdb-patches at sourceware dot org
- Date: Tue, 03 Mar 2015 19:34:43 +0100
- 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>
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
> 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