Skip to content

Commit b5a85b3

Browse files
committed
[net] Delete CNetMessage copy constructor/assignment op
1 parent 630756c commit b5a85b3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/net.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ class CNetMessage {
236236
std::string m_type;
237237

238238
CNetMessage(CDataStream&& recv_in) : m_recv(std::move(recv_in)) {}
239+
// Only one CNetMessage object will exist for the same message on either
240+
// the receive or processing queue. For performance reasons we therefore
241+
// delete the copy constructor and assignment operator to avoid the
242+
// possibility of copying CNetMessage objects.
243+
CNetMessage(CNetMessage&&) = default;
244+
CNetMessage(const CNetMessage&) = delete;
245+
CNetMessage& operator=(CNetMessage&&) = default;
246+
CNetMessage& operator=(const CNetMessage&) = delete;
239247

240248
void SetVersion(int nVersionIn)
241249
{

0 commit comments

Comments
 (0)