diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-03-16 16:52:15 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-03-16 16:52:15 +0000 |
commit | 430db103f682457f7cc0e7198e03ef6ddb4a76ad (patch) | |
tree | e006b3971d5506dfcf47304de06c94a5659bbf6b | |
parent | 70d0961658447a5a2ffea118d392a0776d3dd689 (diff) | |
download | nginx-430db103f682457f7cc0e7198e03ef6ddb4a76ad.tar.gz nginx-430db103f682457f7cc0e7198e03ef6ddb4a76ad.zip |
speed up ngx_http_charset_recode() for 25%: google-perftools reported
that CPU usage of charset body filter has decreased from 7.5% to 5.5%
if gzipping is disabled
-rw-r--r-- | src/http/modules/ngx_http_charset_filter_module.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c index f7d9906a8..850e64e75 100644 --- a/src/http/modules/ngx_http_charset_filter_module.c +++ b/src/http/modules/ngx_http_charset_filter_module.c @@ -561,25 +561,33 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) static ngx_uint_t ngx_http_charset_recode(ngx_buf_t *b, u_char *table) { - u_char *p; + u_char *p, *last; - for (p = b->pos; p < b->last; p++) { + last = b->last; - if (*p == table[*p]) { - continue; + for (p = b->pos; p < last; p++) { + + if (*p != table[*p]) { + goto recode; } + } + + return 0; - while (p < b->last) { +recode: + + do { + if (*p != table[*p]) { *p = table[*p]; - p++; } - b->in_file = 0; + p++; - return 1; - } + } while (p < last); - return 0; + b->in_file = 0; + + return 1; } |