diff src/http/modules/ngx_http_charset_filter_module.c @ 370:9a242235a80a NGINX_0_6_29

nginx 0.6.29 *) Feature: the ngx_google_perftools_module. *) Bugfix: the ngx_http_perl_module could be not built on 64-bit platforms; bug appeared in 0.6.27.
author Igor Sysoev <http://sysoev.ru>
date Tue, 18 Mar 2008 00:00:00 +0300
parents 4276c2f1f434
children 3ce4580ae286
line wrap: on
line diff
--- 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_re
 static ngx_uint_t
 ngx_http_charset_recode(ngx_buf_t *b, u_char *table)
 {
-    u_char  *p;
-
-    for (p = b->pos; p < b->last; p++) {
+    u_char  *p, *last;
 
-        if (*p == table[*p]) {
-            continue;
-        }
+    last = b->last;
 
-        while (p < b->last) {
-            *p = table[*p];
-            p++;
+    for (p = b->pos; p < last; p++) {
+
+        if (*p != table[*p]) {
+            goto recode;
         }
-
-        b->in_file = 0;
-
-        return 1;
     }
 
     return 0;
+
+recode:
+
+    do {
+        if (*p != table[*p]) {
+            *p = table[*p];
+        }
+
+        p++;
+
+    } while (p < last);
+
+    b->in_file = 0;
+
+    return 1;
 }