strbuf: do not calculate next step in size on all calls

We only need to check if the new size is less or equal than the current
size. We don't really need to calculate the next step.
This commit is contained in:
Lucas De Marchi 2014-10-16 21:22:32 -03:00
parent 405b8927fe
commit 8863154e44
1 changed files with 3 additions and 3 deletions

View File

@ -33,14 +33,14 @@ static bool buf_grow(struct strbuf *buf, size_t newsize)
void *tmp;
size_t sz;
if (newsize <= buf->size)
return true;
if (newsize % BUF_STEP == 0)
sz = newsize;
else
sz = ((newsize / BUF_STEP) + 1) * BUF_STEP;
if (buf->size == sz)
return true;
tmp = realloc(buf->bytes, sz);
if (sz > 0 && tmp == NULL)
return false;