Archived
Micro-optimisation: Merge append_byte_to_buffer with append_to_buffer
This makes the cborencoder.o only 986 bytes with -Os on x86-64. The function is still inlined with -O2. Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
+1
-12
@@ -106,18 +106,7 @@ static inline CborError append_to_buffer(CborEncoder *encoder, const void *data,
|
||||
|
||||
static inline CborError append_byte_to_buffer(CborEncoder *encoder, uint8_t byte)
|
||||
{
|
||||
if (would_overflow(encoder, 1)) {
|
||||
if (encoder->end != NULL) {
|
||||
encoder->end = NULL;
|
||||
encoder->bytes_needed = 0;
|
||||
}
|
||||
|
||||
advance_ptr(encoder, 1);
|
||||
return CborErrorOutOfMemory;
|
||||
}
|
||||
|
||||
*encoder->ptr++ = byte;
|
||||
return CborNoError;
|
||||
return append_to_buffer(encoder, &byte, 1);
|
||||
}
|
||||
|
||||
static inline CborError encode_number_no_update(CborEncoder *encoder, uint64_t ui, uint8_t shiftedMajorType)
|
||||
|
||||
Reference in New Issue
Block a user