From 4b2badf97c0f944c959f76d67e41d0eb7f45d5f1 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 19 Jan 2020 19:07:10 -0800 Subject: [PATCH] libi2pd: use std::move and pass by value Found with clang-tidy's modernize-pass-by-value Signed-off-by: Rosen Penev --- libi2pd/Datagram.cpp | 3 ++- libi2pd/Garlic.cpp | 3 ++- libi2pd/LeaseSet.cpp | 6 ++++-- libi2pd/RouterInfo.cpp | 5 +++-- libi2pd/RouterInfo.h | 2 +- libi2pd/Streaming.cpp | 4 +++- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libi2pd/Datagram.cpp b/libi2pd/Datagram.cpp index 7e04fce8..40f391e1 100644 --- a/libi2pd/Datagram.cpp +++ b/libi2pd/Datagram.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "Crypto.h" #include "Log.h" @@ -12,7 +13,7 @@ namespace i2p namespace datagram { DatagramDestination::DatagramDestination (std::shared_ptr owner): - m_Owner (owner), m_Receiver (nullptr), m_RawReceiver (nullptr) + m_Owner (std::move(owner)), m_Receiver (nullptr), m_RawReceiver (nullptr) { } diff --git a/libi2pd/Garlic.cpp b/libi2pd/Garlic.cpp index fc8a4f01..7c150b8d 100644 --- a/libi2pd/Garlic.cpp +++ b/libi2pd/Garlic.cpp @@ -2,6 +2,7 @@ #include "I2PEndian.h" #include #include +#include #include "Crypto.h" #include "RouterContext.h" #include "I2NPProtocol.h" @@ -61,7 +62,7 @@ namespace garlic ElGamalAESSession::ElGamalAESSession (GarlicDestination * owner, std::shared_ptr destination, int numTags, bool attachLeaseSet): GarlicRoutingSession (owner, attachLeaseSet), - m_Destination (destination), m_NumTags (numTags) + m_Destination (std::move(destination)), m_NumTags (numTags) { // create new session tags and session key RAND_bytes (m_SessionKey, 32); diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index e6373dd9..f2fd809d 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -1,4 +1,6 @@ #include + +#include #include "I2PEndian.h" #include "Crypto.h" #include "Log.h" @@ -652,7 +654,7 @@ namespace data } LocalLeaseSet::LocalLeaseSet (std::shared_ptr identity, const uint8_t * encryptionPublicKey, std::vector > tunnels): - m_ExpirationTime (0), m_Identity (identity) + m_ExpirationTime (0), m_Identity (std::move(identity)) { int num = tunnels.size (); if (num > MAX_NUM_LEASES) num = MAX_NUM_LEASES; @@ -689,7 +691,7 @@ namespace data } LocalLeaseSet::LocalLeaseSet (std::shared_ptr identity, const uint8_t * buf, size_t len): - m_ExpirationTime (0), m_Identity (identity) + m_ExpirationTime (0), m_Identity (std::move(identity)) { if (buf) { diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp index 37c2af7e..b2493d2d 100644 --- a/libi2pd/RouterInfo.cpp +++ b/libi2pd/RouterInfo.cpp @@ -2,6 +2,7 @@ #include #include "I2PEndian.h" #include +#include #include #include #if (BOOST_VERSION >= 105300) @@ -25,8 +26,8 @@ namespace data m_Addresses = boost::make_shared(); // create empty list } - RouterInfo::RouterInfo (const std::string& fullPath): - m_FullPath (fullPath), m_IsUpdated (false), m_IsUnreachable (false), + RouterInfo::RouterInfo (std::string fullPath): + m_FullPath (std::move(fullPath)), m_IsUpdated (false), m_IsUnreachable (false), m_SupportedTransports (0), m_Caps (0) { m_Addresses = boost::make_shared(); // create empty list diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h index b23625e0..ac4f66fb 100644 --- a/libi2pd/RouterInfo.h +++ b/libi2pd/RouterInfo.h @@ -132,7 +132,7 @@ namespace data typedef std::list > Addresses; RouterInfo (); - RouterInfo (const std::string& fullPath); + RouterInfo (std::string fullPath); RouterInfo (const RouterInfo& ) = default; RouterInfo& operator=(const RouterInfo& ) = default; RouterInfo (const uint8_t * buf, int len); diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index 4f943912..fe186b53 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -7,6 +7,8 @@ #include "Destination.h" #include "Streaming.h" +#include + namespace i2p { namespace stream @@ -963,7 +965,7 @@ namespace stream } StreamingDestination::StreamingDestination (std::shared_ptr owner, uint16_t localPort, bool gzip): - m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip), + m_Owner (std::move(owner)), m_LocalPort (localPort), m_Gzip (gzip), m_PendingIncomingTimer (m_Owner->GetService ()) { }