This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: on the speed of std::string::find


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]