Browse Source

[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
personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
bc25684f0c
  1. 3
      src/buffer.c

3
src/buffer.c

@ -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 {

Loading…
Cancel
Save