NetworkPacket: don't copy push std::string and std::wstring
authorLoic Blot <loic.blot@unix-experience.fr>
Fri, 14 Apr 2017 16:26:24 +0000 (18:26 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Fri, 14 Apr 2017 16:26:24 +0000 (18:26 +0200)
src/network/networkpacket.cpp
src/network/networkpacket.h

index 91e6c58e2ad370d43ea008ee2d0fc2b7d8bdc5e7..f7a6499ddbcbe032f4b33ddc8a9d50b75f61077e 100644 (file)
@@ -105,7 +105,7 @@ NetworkPacket& NetworkPacket::operator>>(std::string& dst)
        return *this;
 }
 
-NetworkPacket& NetworkPacket::operator<<(std::string src)
+NetworkPacket& NetworkPacket::operator<<(const std::string &src)
 {
        u16 msgsize = src.size();
        if (msgsize > STRING_MAX_LEN) {
@@ -119,7 +119,7 @@ NetworkPacket& NetworkPacket::operator<<(std::string src)
        return *this;
 }
 
-void NetworkPacket::putLongString(std::string src)
+void NetworkPacket::putLongString(const std::string &src)
 {
        u32 msgsize = src.size();
        if (msgsize > LONG_STRING_MAX_LEN) {
@@ -155,7 +155,7 @@ NetworkPacket& NetworkPacket::operator>>(std::wstring& dst)
        return *this;
 }
 
-NetworkPacket& NetworkPacket::operator<<(std::wstring src)
+NetworkPacket& NetworkPacket::operator<<(const std::wstring &src)
 {
        u16 msgsize = src.size();
        if (msgsize > WIDE_STRING_MAX_LEN) {
index 3e436aba9e72f8595503bc7b0a216ceef1b776bc..83dc33f6f5d98b4ef5c007f022a07bea9d434133 100644 (file)
@@ -52,12 +52,12 @@ public:
                        { putRawString(src.c_str(), src.size()); }
 
                NetworkPacket& operator>>(std::string& dst);
-               NetworkPacket& operator<<(std::string src);
+               NetworkPacket& operator<<(const std::string &src);
 
-               void putLongString(std::string src);
+               void putLongString(const std::string &src);
 
                NetworkPacket& operator>>(std::wstring& dst);
-               NetworkPacket& operator<<(std::wstring src);
+               NetworkPacket& operator<<(const std::wstring &src);
 
                std::string readLongString();