mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-06-09 23:57:38 +02:00
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:
parent
438bad28e6
commit
c92afb675e
5
zmq.hpp
5
zmq.hpp
@ -393,11 +393,10 @@ namespace zmq
|
|||||||
|
|
||||||
inline bool operator==(const message_t &other) const ZMQ_NOTHROW
|
inline bool operator==(const message_t &other) const ZMQ_NOTHROW
|
||||||
{
|
{
|
||||||
|
size_t my_size = size ();
|
||||||
if (size () != other.size ())
|
if (size () != other.size ())
|
||||||
return false;
|
return false;
|
||||||
const std::string a(data<char>(), size());
|
return 0 == memcmp (data (), other.data (), my_size);
|
||||||
const std::string b(other.data<char>(), other.size());
|
|
||||||
return a == b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const message_t &other) const ZMQ_NOTHROW
|
inline bool operator!=(const message_t &other) const ZMQ_NOTHROW
|
||||||
|
Loading…
x
Reference in New Issue
Block a user