From 3112b9477e9a4e58e95f11b90d539d7d5426bafc Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Tue, 14 Nov 2017 22:17:06 +0800 Subject: [PATCH] optimize performance Reduce memory allocation times Signed-off-by: Jianhui Zhao --- src/uhttp_buf.c | 2 +- src/uhttp_buf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uhttp_buf.c b/src/uhttp_buf.c index e549019..a81a85f 100755 --- a/src/uhttp_buf.c +++ b/src/uhttp_buf.c @@ -49,7 +49,7 @@ size_t uh_buf_append(struct uh_buf *buf, const void *data, size_t len) return 0; if (buf->len + len > buf->size) { - if (uh_buf_grow(buf, len * UH_BUF_SIZE_MULTIPLIER) == -1) + if (uh_buf_grow(buf, len << UH_BUF_SIZE_MULTIPLIER) == -1) len = buf->size - buf->len; } diff --git a/src/uhttp_buf.h b/src/uhttp_buf.h index 0b528d9..d5cef12 100755 --- a/src/uhttp_buf.h +++ b/src/uhttp_buf.h @@ -5,7 +5,7 @@ #include #include -#define UH_BUF_SIZE_MULTIPLIER 1.5 +#define UH_BUF_SIZE_MULTIPLIER 3 struct uh_buf { char *base; /* Buffer pointer */