bc: optimize bc_vec_concat()

function                                             old     new   delta
bc_vec_concat                                         71      66      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-12-10 15:12:58 +01:00
parent a7f1a36540
commit 8b4cf0dbb0

View File

@ -1165,13 +1165,14 @@ static void bc_vec_string(BcVec *v, size_t len, const char *str)
static void bc_vec_concat(BcVec *v, const char *str)
{
size_t len;
size_t len, slen;
if (v->len == 0) bc_vec_pushZeroByte(v);
len = v->len + strlen(str);
slen = strlen(str);
len = v->len + slen;
if (v->cap < len) bc_vec_grow(v, len - v->len);
if (v->cap < len) bc_vec_grow(v, slen);
strcpy(v->v + v->len - 1, str);
v->len = len;