This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: on the speed of std::string::find
Paolo Carlini wrote:
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.
Note, I have to warn you that a standard conforming implementation of
this optimization may not be completely trivial, we have to think a bit
about it. The issue is that std::basic_string admits '\0' in the middle,
and you would want to call a mem* functions working on char arrays (like
in the implementation of char_traits), not str* functions for this kind
of delegation. But, AFAIK, the C library doesn't deliver such functions...
Paolo.