mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-15 09:25:37 +02:00
serialize.h: use machine native byte swapping if available, fall-back to previous generic method if not (supported for GCC using endian.h, detection done in cmake) write/readARGB8() - just write 32-bit color in one op, instead of 4 1-byte ops cleanup: removed unneeded buffer init for some serialize-out functions use a #define for the fixed point factor in read/writeF1000()
nodemetadata.cpp, nodetimer.cpp optimzation: simpler deserialize node position method staticobject.cpp: cleanup: use util/serialize.h inlines instead of its own de/serialization serialize.cpp: minor optimization/cleanup: avoid generation of unneeded string temporary CMakeLists.txt, cmake_config.h.in: detection of endian.h config.h: added HAVE_ENDIAN_H Commits due to feedback squashed Signed-off-by: Craig Robbins <kde.psych@gmail.com>
This commit is contained in:
committed by
Craig Robbins
parent
d406ac994b
commit
f7d65091f8
@@ -68,11 +68,11 @@ std::string deSerializeString(std::istream &is)
|
||||
if(is.gcount() != 2)
|
||||
throw SerializationError("deSerializeString: size not read");
|
||||
u16 s_size = readU16((u8*)buf);
|
||||
std::string s;
|
||||
if(s_size == 0)
|
||||
return "";
|
||||
return s;
|
||||
Buffer<char> buf2(s_size);
|
||||
is.read(&buf2[0], s_size);
|
||||
std::string s;
|
||||
s.reserve(s_size);
|
||||
s.append(&buf2[0], s_size);
|
||||
return s;
|
||||
@@ -86,9 +86,9 @@ std::wstring deSerializeWideString(std::istream &is)
|
||||
if(is.gcount() != 2)
|
||||
throw SerializationError("deSerializeString: size not read");
|
||||
u16 s_size = readU16((u8*)buf);
|
||||
if(s_size == 0)
|
||||
return L"";
|
||||
std::wstring s;
|
||||
if(s_size == 0)
|
||||
return s;
|
||||
s.reserve(s_size);
|
||||
for(u32 i=0; i<s_size; i++)
|
||||
{
|
||||
@@ -118,11 +118,11 @@ std::string deSerializeLongString(std::istream &is)
|
||||
if(is.gcount() != 4)
|
||||
throw SerializationError("deSerializeLongString: size not read");
|
||||
u32 s_size = readU32((u8*)buf);
|
||||
std::string s;
|
||||
if(s_size == 0)
|
||||
return "";
|
||||
return s;
|
||||
Buffer<char> buf2(s_size);
|
||||
is.read(&buf2[0], s_size);
|
||||
std::string s;
|
||||
s.reserve(s_size);
|
||||
s.append(&buf2[0], s_size);
|
||||
return s;
|
||||
|
||||
Reference in New Issue
Block a user