From 9ffcdaf02b2c51d8f3e4f92402d2445699b48aa3 Mon Sep 17 00:00:00 2001 From: Greg Ames Date: Tue, 24 Jul 2001 22:55:29 +0000 Subject: [PATCH] Reduce CPU consumption in conv_10 function, used to format "%d" by apr_*printf This includes two changes to APR: * new functions apr_itoa, apr_ltoa, and apr_off_t_toa that provide itoa-type functionality based on pools * Inline code in inet_ntop4 to replace sprintf for converting binary IP addresses into dotted-decimal format and two changes to Apache: * use the apr_itoa functions in setting the content length, in place of apr_psprintf * use the apr_itoa functions to replace frequent uses of 'sprintf("%d",...)' in mod_log_config. Submitted by: Brian Pane Reviewed by: Dean Gaudet, Greg Ames git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89686 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ modules/loggers/mod_log_config.c | 4 ++-- server/protocol.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index f459919053..66dd303582 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,9 @@ Changes with Apache 2.0.22-dev + + *) Use new APR number conversion functions to reduce CPU consumption + when setting the content length, and in mod_log_config. + [Brian Pane] + *) Fix problem reported by Taketo Kabe where HEAD response headers were being repeated twice for files greater than 32K bytes (4*AP_MIN_BYTES_TO_WRITE). This diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index 1b801cc79f..c42fdb03c6 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -284,7 +284,7 @@ typedef struct { static char *format_integer(apr_pool_t *p, int i) { - return apr_psprintf(p, "%d", i); + return apr_itoa(p, i); } static char *pfmt(apr_pool_t *p, int i) @@ -381,7 +381,7 @@ static const char *clf_log_bytes_sent(request_rec *r, char *a) return "-"; } else { - return apr_psprintf(r->pool, "%ld", r->bytes_sent); + return apr_ltoa(r->pool, r->bytes_sent); } } diff --git a/server/protocol.c b/server/protocol.c index b8ec3cc6ab..d62a1fa78f 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -154,7 +154,7 @@ AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t clength) { r->clength = clength; apr_table_setn(r->headers_out, "Content-Length", - apr_psprintf(r->pool, "%" APR_OFF_T_FMT, clength)); + apr_off_t_toa(r->pool, clength)); } /* -- 2.40.0