Browse Source

pass I2NPMessage by move

pull/1698/head
orignal 3 years ago
parent
commit
d310efcb5c
  1. 2
      libi2pd/I2NPProtocol.cpp
  2. 2
      libi2pd/I2NPProtocol.h
  3. 5
      libi2pd/NTCP2.cpp
  4. 2
      libi2pd/SSUData.cpp
  5. 2
      libi2pd/Transports.cpp

2
libi2pd/I2NPProtocol.cpp

@ -860,7 +860,7 @@ namespace i2p @@ -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)
{

2
libi2pd/I2NPProtocol.h

@ -301,7 +301,7 @@ namespace tunnel @@ -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:

5
libi2pd/NTCP2.cpp

@ -876,11 +876,12 @@ namespace transport @@ -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:

2
libi2pd/SSUData.cpp

@ -247,7 +247,7 @@ namespace transport @@ -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");

2
libi2pd/Transports.cpp

@ -389,7 +389,7 @@ namespace transport @@ -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;
}

Loading…
Cancel
Save