on the speed of std::string::find

Paolo Carlini pcarlini@suse.de
Fri Sep 1 11:42:00 GMT 2006


Dennis Lubert wrote:

>>First, which version of gcc are you using? 
>>    
>>
>Please look up, its gcc 4.1.
>  
>
Ok, just say it...

>>Recent versions simply 
>>delegate to the std::search in <algorithm>, which was benchmarked to be 
>>much faster than an algorithm based on char_traits::find, thus memchr, 
>>basically. Of course we are talking here about the overload of 
>>string::find exactly corresponding to strstr (that is, search a whole 
>>string inside another one), because the other, "simpler", overloads, all 
>>delegate already to memchr (via char_traits::memchr).
>>    
>>
>Yes, my version mainly delegates to std::search (only for the search for
>a single character, it delegates to char_traits::find).
>  
>
To be sure: by "my version" you mean, the version you find delivered in 
libstdc++-v3. Because you are instead calling strstr, when possible. To 
summarize, that would boil down to providing specializations of find for 
std::char_traits, char/wchar_t not using generic algorithms but calling 
strstr and  wcsstr directly instead. Can you please file an enhancement 
PR, possibly including a small performance test?

Thanks,
Paolo.



More information about the Libstdc++ mailing list