SerializationFormat: move realloc() call out of the loop

Reallocate and copy the data only once.
This commit is contained in:
Max Kellermann 2020-01-27 08:50:54 +01:00
parent ef15467757
commit 61c3be8e16

View file

@ -81,8 +81,8 @@ bool SerializationFormat::WriteData(const void* b, size_t count)
while ( output_pos + count > output_size )
{
output_size *= GROWTH_FACTOR;
output = (char*)safe_realloc(output, output_size);
}
output = (char*)safe_realloc(output, output_size);
memcpy(output + output_pos, b, count);
output_pos += count;