[PATCH] improve string find algorithm

Manfred mx2927@gmail.com
Tue Jan 10 16:12:00 GMT 2017


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?



More information about the Libstdc++ mailing list