summaryrefslogtreecommitdiff
path: root/src/chunk.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2018-11-23 00:37:38 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2018-11-23 00:37:38 -0500
commitf69bd9cdb89f7288c982fafe550cc8f1297d08ca (patch)
treeea66c7a21cda103eb6b34c6672df8957a8c371c8 /src/chunk.c
parent9749503b1dc221aed4ba6e215c6acb893d8281be (diff)
downloadlighttpd-git-f69bd9cdb89f7288c982fafe550cc8f1297d08ca.tar.gz
[core] perf: simple, quick buffer_clear()
quickly clear buffer instead of buffer_string_set_length(b, 0) or buffer_reset(b). Avoids free() of large buffers about to be reused, or buffers that are module-scoped, persistent, and reused. (buffer_reset() should still be used with buffers in connection *con when the data in the buffers is supplied by external, untrusted source)
Diffstat (limited to 'src/chunk.c')
-rw-r--r--src/chunk.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/chunk.c b/src/chunk.c
index 4d55a3de..4489a854 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -99,7 +99,7 @@ static void chunk_reset_file_chunk(chunk *c) {
static void chunk_reset(chunk *c) {
if (c->type == FILE_CHUNK) chunk_reset_file_chunk(c);
- buffer_string_set_length(c->mem, 0);
+ buffer_clear(c->mem);
c->offset = 0;
}
@@ -134,7 +134,7 @@ void chunk_buffer_release(buffer *b) {
c->mem = b;
c->next = chunks;
chunks = c;
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
}
else {
buffer_free(b);
@@ -426,7 +426,7 @@ void chunkqueue_use_memory(chunkqueue *cq, size_t len) {
/* unused buffer: can't remove chunk easily from
* end of list, so just reset the buffer
*/
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
}
}