This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 3/4] Use pointers for traversing arrays in strstr, strcasestrand memmem.
- From: Carlos O'Donell <carlos_odonell at mentor dot com>
- To: Maxim Kuvyrkov <maxim at codesourcery dot com>
- Cc: Carlos O'Donell <carlos at codesourcery dot com>, GLIBC Devel<libc-alpha at sourceware dot org>, Eric Blake <eblake at redhat dot com>, Ryan Arnold<rsa at us dot ibm dot com>
- Date: Tue, 21 Aug 2012 08:28:51 -0400
- Subject: Re: [PATCH 3/4] Use pointers for traversing arrays in strstr, strcasestrand memmem.
- References: <2C516CF2-D083-4C1D-AD27-6A31D381D548@codesourcery.com> <D2F81944-1466-4374-93E4-C347F5475ACF@codesourcery.com> <502DB1A1.8090302@mentor.com> <C4BE6236-E9A8-4FD9-9725-400DF93DC62C@codesourcery.com>
On 8/20/2012 7:31 PM, Maxim Kuvyrkov wrote:
> On 17/08/2012, at 2:51 PM, Carlos O'Donell wrote:
>
>> On 5/30/2012 5:11 AM, Maxim Kuvyrkov wrote:
>>> [PATCH 3/4] Use pointers for traversing arrays in strstr, strcasestr and memmem.
>>>
> ...
>>> + const unsigned char *phaystack = &haystack[suffix];
>>> /* The comparison always starts from needle[suffix], so cache it
>>> and use an optimized first-character loop. */
>>> unsigned char needle_suffix = CANON_ELEMENT (needle[suffix]);
>>> @@ -282,23 +290,28 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
>>> while (AVAILABLE1 (haystack, haystack_len, j, needle_len))
>>> {
>>> unsigned char a;
>>> + const unsigned char *pneedle;
>>
>> (1) Use a meaningful variable name please.
>
> Any suggestions? I think p<foo> is a fairly standard name for a pointer to <foo>. Do you think haystack_ptr and needle_ptr sound better?
I made a mistake here. I apologize. The use of `pneedle' is fine.
My gripe was actually with the use of `unsigned char a', which
was actually added by an earlier patch and I have already
commented on it.
Cheers,
Carlos.
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell@mentor.com
carlos@codesourcery.com
+1 (613) 963 1026