[core] perf: buffer_string_append_len()
buffer_string_append_len() short-circuit common case,
but preserve blank-string initialization side-effect
if buffer is empty
@@ -128,6 +128,9 @@ char* buffer_string_prepare_copy(buffer *b, size_t size) {
char* buffer_string_prepare_append(buffer *b, size_t size) {
force_assert(NULL != b);
+ if (b->used && size < b->size - b->used)
+ return b->ptr + b->used - 1;
+
if (buffer_string_is_empty(b)) {
return buffer_string_prepare_copy(b, size);
} else {
