basic/strbuf: include empty strings in count
Not that it matters much, but it seems cleaner to also count those inputs, even if they do not consume extra storage space. The test is extended to include an empty input and counts in the test are adjusted to include it.
This commit is contained in:
+5
-2
@@ -133,9 +133,12 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
|
||||
return -EINVAL;
|
||||
|
||||
/* search string; start from last character to find possibly matching tails */
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
str->in_count++;
|
||||
if (len == 0) {
|
||||
str->dedup_count++;
|
||||
return 0;
|
||||
}
|
||||
str->in_len += len;
|
||||
|
||||
node = str->root;
|
||||
|
||||
Reference in New Issue
Block a user