Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
1.0.0
-
None
Description
messageqcpp::ByteStream was refactored and it was identified to have some inefficiencies. In the prior version it had a constructor and assignment operator that accepted shared_ptr<ByteStream> . This resulted in a lot of compiler implicit copies which arent immediately obvious. For example:
ByteStream ClientRotator::read(){
mutex::scoped_lock lk(fClientLock);
ByteStream bs;
if (!fClient)
connect();
try
{
bs = fClient->read();
return bs;
here fClient->read() returns a shared_ptr<ByteStream> where a temporary ByteStream is copied into then the temporary is assigned to bs. If RVO weren't performed a third copy would get returned to the caller. A better option here is for ClientRotator::read() to return shared_ptr<ByteStream> and avoid the copies. It's unclear where or how many of these are in the code base. Upon first look liboamcpp.cpp has a lot of inefficiencies. All usage should be investigated.