mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Optimise strbuf_ncat()
Do not write nul unnecessarily.
This commit is contained in:
parent
fc67b38fd2
commit
0dd778bab5
2
strbuf.c
2
strbuf.c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user