Optimise strbuf_ncat()

Do not write nul unnecessarily.
This commit is contained in:
Andrew Bettison 2015-11-17 00:17:02 +10:30
parent fc67b38fd2
commit 0dd778bab5

View File

@ -42,7 +42,7 @@ strbuf strbuf_reset(strbuf sb)
strbuf strbuf_ncat(strbuf sb, const char *text, size_t len)
{
if (sb->start && (!sb->end || (sb->current < sb->end))) {
if (len && sb->start && (!sb->end || (sb->current < sb->end))) {
register size_t n = sb->end ? min(sb->end - sb->current, len) : len;
char *c;
for (c = sb->current; n && (*c = *text); --n, ++c, ++text)