optimization

This commit is contained in:
Robin Müller 2020-08-25 13:37:42 +02:00
parent fb0a3d22db
commit de98dd0871

View File

@ -23,16 +23,6 @@ SerialBufferAdapter<count_t>::~SerialBufferAdapter() {
template<typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer,
size_t* size, size_t maxSize, Endianness streamEndianness) const {
count_t serializedLength = bufferLength;
if (serializeLength) {
serializedLength += SerializeAdapter::getSerializedSize(
&bufferLength);
}
if (*size + serializedLength > maxSize) {
return BUFFER_TOO_SHORT;
}
if (serializeLength) {
ReturnValue_t result = SerializeAdapter::serialize(&bufferLength,
buffer, size, maxSize, streamEndianness);
@ -41,6 +31,10 @@ ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer,
}
}
if (*size + bufferLength > maxSize) {
return BUFFER_TOO_SHORT;
}
if (this->constBuffer != nullptr) {
std::memcpy(*buffer, this->constBuffer, bufferLength);
}