]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hpack: use ist2bin() to copy header names in hpack_encode_header()
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Dec 2018 05:27:06 +0000 (06:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Dec 2018 08:06:46 +0000 (09:06 +0100)
memcpy() tends to be overkill to copy short strings, better use ist's
naive functions for this. This shows a consistent 1.2% performance
gain with h2load.

src/hpack-enc.c

index 7c6ef6f80077ce89812307657bfd53eb2bc8846a..73a5fd16718f76db5a0891055ed95dcaa9cca122 100644 (file)
@@ -116,9 +116,8 @@ int hpack_encode_header(struct buffer *out, const struct ist n,
                out->area[len++] = 0x5c; // literal with indexing -- name="content-length" (idx 28)
        else if (len_to_bytes(n.len) && len + 1 + len_to_bytes(n.len) + n.len <= size) {
                out->area[len++] = 0x00;      /* literal without indexing -- new name */
-
                len = hpack_encode_len(out->area, len, n.len);
-               memcpy(out->area + len, n.ptr, n.len);
+               ist2bin(out->area + len, n);
                len += n.len;
        }
        else {