Browse Source

[core] perf: inline buffer_copy_buffer()

personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
cf93e91c56
  1. 8
      src/buffer.c
  2. 6
      src/buffer.h
  3. 2
      src/http-header-glue.c

8
src/buffer.c

@ -168,14 +168,6 @@ void buffer_copy_string_len(buffer *b, const char *s, size_t s_len) {
b->used = s_len + 1;
}
void buffer_copy_buffer(buffer *b, const buffer *src) {
if (NULL == src || 0 == src->used) {
buffer_string_prepare_copy(b, 0);
} else {
buffer_copy_string_len(b, src->ptr, buffer_string_length(src));
}
}
void buffer_append_string(buffer *b, const char *s) {
buffer_append_string_len(b, s, NULL != s ? strlen(s) : 0);
}

6
src/buffer.h

@ -74,7 +74,7 @@ static inline void buffer_clear(buffer *b);
void buffer_copy_string(buffer *b, const char *s);
void buffer_copy_string_len(buffer *b, const char *s, size_t s_len);
void buffer_copy_buffer(buffer *b, const buffer *src);
static inline void buffer_copy_buffer(buffer *b, const buffer *src);
void buffer_append_string(buffer *b, const char *s);
void buffer_append_string_len(buffer *b, const char *s, size_t s_len);
@ -204,6 +204,10 @@ static inline size_t buffer_string_space(const buffer *b) {
return NULL != b && b->size ? b->size - (b->used | (0 == b->used)) : 0;
}
static inline void buffer_copy_buffer(buffer *b, const buffer *src) {
buffer_copy_string_len(b, CONST_BUF_LEN(src));
}
static inline void buffer_append_string_buffer(buffer *b, const buffer *src) {
buffer_append_string_len(b, CONST_BUF_LEN(src));
}

2
src/http-header-glue.c

@ -30,7 +30,7 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
buffer_copy_buffer(o, con->uri.scheme);
buffer_append_string_len(o, CONST_STR_LEN("://"));
if (!buffer_is_empty(con->uri.authority)) {
if (!buffer_string_is_empty(con->uri.authority)) {
buffer_append_string_buffer(o, con->uri.authority);
} else {
/* get the name of the currently connected socket */

Loading…
Cancel
Save