Hi,
VSB_bcat calls VSB_put_byte for each char that needs to append.
Since we know the length it's better to extend the buffer if needed and
just memcpy the whole input.
Comments? OK?
diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c
index 92abdf2..ad98c8a 100644
--- a/lib/libvarnish/vsb.c
+++ b/lib/libvarnish/vsb.c
@@ -278,20 +278,20 @@ VSB_put_byte(struct vsb *s, int c)
int
VSB_bcat(struct vsb *s, const void *buf, size_t len)
{
- const char *str = buf;
- const char *end = str + len;
-
assert_VSB_integrity(s);
assert_VSB_state(s, 0);
if (s->s_error != 0)
return (-1);
_vsb_indent(s);
- for (; str < end; str++) {
- VSB_put_byte(s, *str);
+ if (len > VSB_FREESPACE(s)) {
+ if (VSB_extend(s, len - VSB_FREESPACE(s)) < 0)
+ s->s_error = ENOMEM;
if (s->s_error != 0)
return (-1);
}
+ memcpy(s->s_buf + s->s_len, buf, len);
+ s->s_len += len;
return (0);
}
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev