This is the mail archive of the
mailing list for the GCC project.
- From: "Jari Sundell" <sundell dot software at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 20 Jul 2007 03:12:23 +0200
- Subject: std::string::operator==/!= optimization
Looking at the std::string comparison operators, they all seem to be
using std::string::compare directly even in cases where the string
lengths must match. Comparing the string lengths before the
std::string::compare call in std::string::operator==/!= would avoid
doing a byte-for-byte comparison in most cases where unequal strings
A quick glance at the object code shows that the new conditional
replaces the std::min in std::string::compare in addition to reducing
the code size slightly, when compiled with -O2.
Or is there some specific reasons why this isn't done?