Browse Source

[core] perf: skip redundant prepare copy calls

skip redundant calls to buffer_string_prepare_copy() when simply
clearing buffer is sufficient, e.g. when a blanked buffer is desired
before calling buffer_append_strftime(), which internally prepares
buffer for the resultant formatted string
personal/stbuehler/fix-fdevent
Glenn Strauss 4 years ago
parent
commit
929909a999
  1. 2
      src/log.c
  2. 2
      src/mod_accesslog.c
  3. 2
      src/mod_expire.c
  4. 2
      src/response.c

2
src/log.c

@ -123,7 +123,7 @@ static int log_buffer_prepare(buffer *b, server *srv, const char *filename, unsi
if (-1 == srv->errorlog_fd) return -1;
/* cache the generated timestamp */
if (srv->cur_ts != srv->last_generated_debug_ts) {
buffer_string_prepare_copy(srv->ts_debug_str, 255);
buffer_string_set_length(srv->ts_debug_str, 0);
buffer_append_strftime(srv->ts_debug_str, "%Y-%m-%d %H:%M:%S", localtime(&(srv->cur_ts)));
srv->last_generated_debug_ts = srv->cur_ts;

2
src/mod_accesslog.c

@ -882,7 +882,7 @@ REQUESTDONE_FUNC(log_access_write) {
# endif /* HAVE_GMTIME_R */
#endif /* HAVE_STRUCT_TM_GMTOFF */
buffer_string_prepare_copy(p->conf.ts_accesslog_str, 255);
buffer_string_set_length(p->conf.ts_accesslog_str, 0);
if (buffer_string_is_empty(f->string)) {
#if defined(HAVE_STRUCT_TM_GMTOFF)

2
src/mod_expire.c

@ -387,7 +387,7 @@ CONNECTION_FUNC(mod_expire_handler) {
/* expires should be at least srv->cur_ts */
if (expires < srv->cur_ts) expires = srv->cur_ts;
buffer_string_prepare_copy(p->expire_tstmp, 255);
buffer_string_set_length(p->expire_tstmp, 0);
buffer_append_strftime(p->expire_tstmp, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(expires)));
/* HTTP/1.0 */

2
src/response.c

@ -87,7 +87,7 @@ int http_response_write_header(server *srv, connection *con) {
/* cache the generated timestamp */
if (srv->cur_ts != srv->last_generated_date_ts) {
buffer_string_prepare_copy(srv->ts_date_str, 255);
buffer_string_set_length(srv->ts_date_str, 0);
buffer_append_strftime(srv->ts_date_str, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(srv->cur_ts)));

Loading…
Cancel
Save