[PATCH] improve string find algorithm
Jonathan Wakely
jwakely@redhat.com
Tue Jan 10 17:38:00 GMT 2017
On 10/01/17 17:12 +0100, Manfred wrote:
>On 1/6/2017 9:20 PM, Jonathan Wakely wrote:
>>+ // Compare the full strings from the first occurrence of __elem0.
>>+ // We already know that __first[0] == __s[0] but compare them again
>>+ // anyway because __s is probably aligned, which helps memcmp.
>>+ if (traits_type::compare(__first, __s, __n) == 0)
>>+ return __first - __data;
>I am not sure if __s being aligned really helps here, given that
>__first in principle is not. Would it be worth testing the performance
>with traits_type::compare running from 1-after __s and __first?
Yes, it's probably worth checking. I assume Aditya or Sebastian did
verify that, because there's a comment in their libc++ patch about it,
but we might get diffeernt results with GCC, or with GNU libc.
More information about the Libstdc++
mailing list