1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 04:04:16 +00:00

pass I2NPMessage by move

This commit is contained in:
orignal 2021-10-17 11:31:37 -04:00
parent 1af9117b80
commit d310efcb5c
5 changed files with 7 additions and 6 deletions

View File

@ -860,7 +860,7 @@ namespace i2p
Flush ();
}
void I2NPMessagesHandler::PutNextMessage (std::shared_ptr<I2NPMessage> msg)
void I2NPMessagesHandler::PutNextMessage (std::shared_ptr<I2NPMessage>&& msg)
{
if (msg)
{

View File

@ -301,7 +301,7 @@ namespace tunnel
public:
~I2NPMessagesHandler ();
void PutNextMessage (std::shared_ptr<I2NPMessage> msg);
void PutNextMessage (std::shared_ptr<I2NPMessage>&& msg);
void Flush ();
private:

View File

@ -876,11 +876,12 @@ namespace transport
break;
}
auto nextMsg = NewI2NPMessage (size);
nextMsg->Align (12); // for possible tunnel msg
nextMsg->Align (6); // for possible tunnel msg
nextMsg->offset += TUNNEL_GATEWAY_HEADER_SIZE; // reserve room for TunnelGateway header
nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header
memcpy (nextMsg->GetNTCP2Header (), frame + offset, size);
nextMsg->FromNTCP2 ();
m_Handler.PutNextMessage (nextMsg);
m_Handler.PutNextMessage (std::move (nextMsg));
break;
}
case eNTCP2BlkTermination:

View File

@ -247,7 +247,7 @@ namespace transport
m_ReceivedMessages.emplace (msgID, m_LastMessageReceivedTime);
if (!msg->IsExpired ())
{
m_Handler.PutNextMessage (msg);
m_Handler.PutNextMessage (std::move (msg));
}
else
LogPrint (eLogDebug, "SSU: message expired");

View File

@ -389,7 +389,7 @@ namespace transport
{
// we send it to ourself
for (auto& it: msgs)
m_LoopbackHandler.PutNextMessage (it);
m_LoopbackHandler.PutNextMessage (std::move (it));
m_LoopbackHandler.Flush ();
return;
}