Browse Source

[core] perf: simplify buffer_move()

require src and dest to be non-NULL

change no longer releases large swapped buffers with buffer_reset()
personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
449274903c
  1. 10
      src/buffer.c
  2. 6
      src/configparser.y

10
src/buffer.c

@ -66,14 +66,10 @@ void buffer_reset(buffer *b) {
void buffer_move(buffer *b, buffer *src) {
buffer tmp;
force_assert(NULL != b);
force_assert(NULL != src);
if (NULL == b) {
buffer_reset(src);
return;
}
buffer_reset(b);
if (NULL == src) return;
buffer_clear(b);
tmp = *src; *src = *b; *b = tmp;
}

6
src/configparser.y

@ -317,9 +317,11 @@ value(A) ::= key(B). {
}
value(A) ::= STRING(B). {
buffer *b;
A = (data_unset *)data_string_init();
buffer_move(((data_string *)(A))->value, B);
buffer_free(B);
b = ((data_string *)(A))->value;
buffer_free(b);
((data_string *)(A))->value = B;
B = NULL;
}

Loading…
Cancel
Save