I am working with a C++ library that was not written by me. Currently, I am trying to improve the library a bit by removing a lot of circular dependencies.
The libray communicates over the network and has some message classes, which are created when reading data received from the network.
Currently, it works like this:
- The message is parsed and a
std::unique_ptr<Message>
is being created. - The Message is passed to the parent object with
std::move(msg)
I removed the circular dependency from the network parser to the parent object and used a signal instead, which emits a std::shared_ptr<Message>
.
I am wondering if it would be a bad idea to just pass the Message by value instead of a shared_ptr
. Would this decrease the performance?
The library passes many objects with unique_ptr
like in this case. Is this good practice?
Thanks in advance
EDIT:
The Message
consists of three unsigned int
and a std::map<string, string>
which will not hold more than a few strings