[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
This commit is contained in:
Glenn Strauss 2018-10-25 03:19:16 -04:00
parent d4a93a531d
commit 929909a999
4 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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 */

View File

@ -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)));