]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: compression: do not test for buffer before calling b_alloc()
authorWilly Tarreau <w@1wt.eu>
Mon, 22 Mar 2021 15:16:22 +0000 (16:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 22 Mar 2021 15:16:22 +0000 (16:16 +0100)
Now we know the function is idempotent, we don't need to run the
preliminary test anymore.

src/compression.c
src/flt_http_comp.c

index 26dcd4283c0092cb796d357a57a51704a43c128c..da6213ed30dada2e238d64fd50d2981cb73f216a 100644 (file)
@@ -294,11 +294,8 @@ static int rfc195x_add_data(struct comp_ctx *comp_ctx, const char *in_data, int
                 * data and need a buffer now. We reuse the same buffer, as it's
                 * not used out of the scope of a series of add_data()*, end().
                 */
-               if (unlikely(!tmpbuf.size)) {
-                       /* this is the first time we need the compression buffer */
-                       if (b_alloc(&tmpbuf) == NULL)
-                               return -1; /* no memory */
-               }
+               if (b_alloc(&tmpbuf) == NULL)
+                       return -1; /* no memory */
                b_reset(&tmpbuf);
                memcpy(b_tail(&tmpbuf), comp_ctx->direct_ptr, comp_ctx->direct_len);
                b_add(&tmpbuf, comp_ctx->direct_len);
index de61cac75c20b583be437b8f61dc58d65dd74542..c9eb16bf92bdd5308352de5237ebb82c8a85a00f 100644 (file)
@@ -66,9 +66,9 @@ comp_flt_init(struct proxy *px, struct flt_conf *fconf)
 static int
 comp_flt_init_per_thread(struct proxy *px, struct flt_conf *fconf)
 {
-       if (!tmpbuf.size && b_alloc(&tmpbuf) == NULL)
+       if (b_alloc(&tmpbuf) == NULL)
                return -1;
-       if (!zbuf.size && b_alloc(&zbuf) == NULL)
+       if (b_alloc(&zbuf) == NULL)
                return -1;
        return 0;
 }