This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/62187] std::string==const char* could compare sizes first
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Jan 2017 15:41:34 +0000
- Subject: [Bug libstdc++/62187] std::string==const char* could compare sizes first
- Auto-submitted: auto-generated
- References: <bug-62187-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62187
--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
Ignoring strange specializations of char_traits, we could also consider a
specialized version of memcmp/strncmp that checks for a terminating 0 in only
one of the 2 strings. This would avoid the call to strlen when the 2 strings
are long but differ early, but on average it would probably turn out slower
than the well optimized strlen+memcmp from libc.