Skip to content

Commit

Permalink
optimize performance
Browse files Browse the repository at this point in the history
Reduce memory allocation times

Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
Jianhui Zhao committed Nov 14, 2017
1 parent f918483 commit 3112b94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/uhttp_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/uhttp_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>
#include <sys/types.h>

#define UH_BUF_SIZE_MULTIPLIER 1.5
#define UH_BUF_SIZE_MULTIPLIER 3

struct uh_buf {
char *base; /* Buffer pointer */
Expand Down

0 comments on commit 3112b94

Please sign in to comment.