Browse Source

[core] perf: array_reset_data_strings()

array_reset_data_strings() specialization
personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
062089ff14
  1. 14
      src/array.c
  2. 1
      src/array.h
  3. 2
      src/connections-glue.c
  4. 6
      src/connections.c
  5. 2
      src/mod_deflate.c
  6. 2
      src/mod_flv_streaming.c
  7. 6
      src/mod_ssi.c
  8. 2
      src/request.c

14
src/array.c

@ -70,6 +70,20 @@ void array_reset(array *a) {
a->unique_ndx = 0;
}
void array_reset_data_strings(array *a) {
if (!a) return;
for (size_t i = 0; i < a->used; ++i) {
data_string * const ds = (data_string *)a->data[i];
/*force_assert(ds->type == TYPE_STRING);*/
buffer_reset(ds->key);
buffer_reset(ds->value);
}
a->used = 0;
a->unique_ndx = 0;
}
data_unset *array_pop(array *a) {
data_unset *du;

1
src/array.h

@ -64,6 +64,7 @@ array *array_init(void);
array *array_init_array(array *a);
void array_free(array *a);
void array_reset(array *a);
void array_reset_data_strings(array *a);
void array_insert_unique(array *a, data_unset *entry);
data_unset *array_pop(array *a); /* only works on "simple" lists with autogenerated keys */
int array_is_vlist(array *a);

2
src/connections-glue.c

@ -501,6 +501,6 @@ void connection_response_reset(server *srv, connection *con) {
buffer_reset(con->physical.etag);
}
con->response.htags = 0;
array_reset(con->response.headers);
array_reset_data_strings(con->response.headers);
http_response_body_clear(con, 0);
}

6
src/connections.c

@ -229,7 +229,7 @@ static void connection_handle_errdoc_init(connection *con) {
buffer_reset(con->physical.path);
con->response.htags = 0;
array_reset(con->response.headers);
array_reset_data_strings(con->response.headers);
http_response_body_clear(con, 0);
if (NULL != www_auth) {
@ -649,8 +649,8 @@ int connection_reset(server *srv, connection *con) {
con->request.te_chunked = 0;
con->request.htags = 0;
array_reset(con->request.headers);
array_reset(con->environment);
array_reset_data_strings(con->request.headers);
array_reset_data_strings(con->environment);
chunkqueue_reset(con->request_content_queue);

2
src/mod_deflate.c

@ -298,7 +298,7 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
s->compression_level = -1;
s->max_loadavg = 0.0;
array_reset(p->encodings); /* temp array for allowed encodings list */
array_reset_data_strings(p->encodings); /* temp array for allowed encodings list */
cv[0].destination = s->mimetypes;
cv[1].destination = p->encodings;

2
src/mod_flv_streaming.c

@ -170,7 +170,7 @@ URIHANDLER_FUNC(mod_flv_streaming_path_handler) {
/* if there is a end=[0-9]+ in the header use it as end pos,
* otherwise send rest of file, starting from start */
array_reset(srv->split_vals);
array_reset_data_strings(srv->split_vals);
split_get_params(srv->split_vals, con->uri.query);
if (NULL != (get_param = (data_string *)array_get_element_klen(srv->split_vals, CONST_STR_LEN("start")))) {

6
src/mod_ssi.c

@ -171,7 +171,7 @@ static int build_ssi_cgi_vars(server *srv, connection *con, handler_ctx *p) {
memset(vb_auth, 0, sizeof(buffer));
}
array_reset(p->ssi_cgi_env);
array_reset_data_strings(p->ssi_cgi_env);
if (0 != http_cgi_headers(srv, con, &opts, ssi_env_add, p->ssi_cgi_env)) {
con->http_status = 400;
@ -1195,8 +1195,8 @@ static int mod_ssi_handle_request(server *srv, connection *con, handler_ctx *p)
/* get a stream to the file */
array_reset(p->ssi_vars);
array_reset(p->ssi_cgi_env);
array_reset_data_strings(p->ssi_vars);
array_reset_data_strings(p->ssi_cgi_env);
buffer_copy_string_len(p->timefmt, CONST_STR_LEN("%a, %d %b %Y %H:%M:%S %Z"));
build_ssi_cgi_vars(srv, con, p);

2
src/request.c

@ -470,7 +470,7 @@ static int parse_single_header(server *srv, connection *con, parse_header_state
case HTTP_HEADER_CONNECTION:
{
array * const vals = srv->split_vals;
array_reset(vals);
array_reset_data_strings(vals);
http_request_split_value(vals, v, vlen); /* split on , */
for (size_t vi = 0; vi < vals->used; ++vi) {
data_string *dsv = (data_string *)vals->data[vi];

Loading…
Cancel
Save