mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Optimizations suggested by Arthur.
This commit is contained in:
@@ -81,28 +81,31 @@ int Serializer::addRaw(const void *ptr, int len)
|
|||||||
bool Serializer::get16(uint16& o, int offset) const
|
bool Serializer::get16(uint16& o, int offset) const
|
||||||
{
|
{
|
||||||
if ((offset + 2) > mData.size()) return false;
|
if ((offset + 2) > mData.size()) return false;
|
||||||
o = mData.at(offset++);
|
unsigned char *ptr = &mData[offset];
|
||||||
o <<= 8; o |= mData.at(offset);
|
o = *ptr++; o <<= 8; o |= *ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::get32(uint32& o, int offset) const
|
bool Serializer::get32(uint32& o, int offset) const
|
||||||
{
|
{
|
||||||
if ((offset + 4) > mData.size()) return false;
|
if ((offset + 4) > mData.size()) return false;
|
||||||
o=mData.at(offset++);
|
unsigned char *ptr = &mData[offset];
|
||||||
o<<=8; o |= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o = *ptr++;
|
||||||
o<<=8; o |= mData.at(offset);
|
o <<= 8; o |= *ptr++;
|
||||||
|
o <<= 8; o |= *ptr++;
|
||||||
|
o <<= 8; o |= *ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::get64(uint64& o, int offset) const
|
bool Serializer::get64(uint64& o, int offset) const
|
||||||
{
|
{
|
||||||
if ((offset + 8) > mData.size()) return false;
|
if ((offset + 8) > mData.size()) return false;
|
||||||
o=mData.at(offset++);
|
unsigned char *ptr = &mData[offset];
|
||||||
o<<=8; o|= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o = *ptr++;
|
||||||
o<<=8; o|= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o <<= 8; o |= *ptr++; o <<= 8; o |= *ptr++;
|
||||||
o<<=8; o|= mData.at(offset++); o <<= 8; o |= mData.at(offset++);
|
o <<= 8; o |= *ptr++; o <<= 8; o |= *ptr++;
|
||||||
o<<=8; o|= mData.at(offset);
|
o <<= 8; o |= *ptr++; o <<= 8; o |= *ptr++;
|
||||||
|
o <<= 8; o |= *ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user