Problem: excessive memory allocations around blob_t (#2796)

* Problem: excessive memory allocations around blob_t

Solution: redefine blob_t as a custom type, and use reference/move
semantics where possible
This commit is contained in:
Simon Giesecke
2017-10-21 13:19:51 +02:00
committed by Luca Boccassi
parent cfef04035c
commit 0897b3e07b
33 changed files with 207 additions and 159 deletions

View File

@@ -48,7 +48,7 @@ zmq::mechanism_t::~mechanism_t ()
void zmq::mechanism_t::set_peer_routing_id (const void *id_ptr, size_t id_size)
{
routing_id = blob_t (static_cast <const unsigned char*> (id_ptr), id_size);
routing_id.set (static_cast <const unsigned char*> (id_ptr), id_size);
}
void zmq::mechanism_t::peer_routing_id (msg_t *msg_)
@@ -61,12 +61,12 @@ void zmq::mechanism_t::peer_routing_id (msg_t *msg_)
void zmq::mechanism_t::set_user_id (const void *data_, size_t size_)
{
user_id = blob_t (static_cast <const unsigned char*> (data_), size_);
user_id.set (static_cast <const unsigned char*> (data_), size_);
zap_properties.insert (metadata_t::dict_t::value_type (
ZMQ_MSG_PROPERTY_USER_ID, std::string ((char *) data_, size_)));
}
zmq::blob_t zmq::mechanism_t::get_user_id () const
const zmq::blob_t &zmq::mechanism_t::get_user_id () const
{
return user_id;
}