Problem: message_t::operator== is absurdly inefficient and constructs temporary copies of both operands

Solution: implement operator== using memcmp instead
This commit is contained in:
Simon Giesecke 2018-04-13 11:28:40 -04:00
parent 438bad28e6
commit c92afb675e

View File

@ -393,11 +393,10 @@ namespace zmq
inline bool operator==(const message_t &other) const ZMQ_NOTHROW
{
size_t my_size = size ();
if (size () != other.size ())
return false;
const std::string a(data<char>(), size());
const std::string b(other.data<char>(), other.size());
return a == b;
return 0 == memcmp (data (), other.data (), my_size);
}
inline bool operator!=(const message_t &other) const ZMQ_NOTHROW