diff options
author | sfan5 <sfan5@live.de> | 2021-09-17 18:14:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 18:14:25 +0200 |
commit | fd8a8501bc26dfca2a93d51000867b8592210040 (patch) | |
tree | 2555456796bc15f7ef0f2bc24c08b9848b874b4e /src/network/networkpacket.cpp | |
parent | ea250ff5c57301b6ea3e529c811484c743c1fde1 (diff) | |
download | minetest-fd8a8501bc26dfca2a93d51000867b8592210040.tar.gz minetest-fd8a8501bc26dfca2a93d51000867b8592210040.tar.bz2 minetest-fd8a8501bc26dfca2a93d51000867b8592210040.zip |
Shave off buffer copies in networking code (#11607)
Diffstat (limited to 'src/network/networkpacket.cpp')
-rw-r--r-- | src/network/networkpacket.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/network/networkpacket.cpp b/src/network/networkpacket.cpp index a71e26572..6b8b0f703 100644 --- a/src/network/networkpacket.cpp +++ b/src/network/networkpacket.cpp @@ -549,14 +549,11 @@ NetworkPacket& NetworkPacket::operator<<(video::SColor src) return *this; } -SharedBuffer<u8> NetworkPacket::oldForgePacket() +Buffer<u8> NetworkPacket::oldForgePacket() { - SharedBuffer<u8> sb(m_datasize + 2); + Buffer<u8> sb(m_datasize + 2); writeU16(&sb[0], m_command); + memcpy(&sb[2], m_data.data(), m_datasize); - u8* datas = getU8Ptr(0); - - if (datas != NULL) - memcpy(&sb[2], datas, m_datasize); return sb; } |