summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-08-04 10:18:36 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-08-04 10:18:36 +0000
commit6a07833d478a9b969dfa8a66041fc8537ee2b8d1 (patch)
treea0e474a1f7f37eb763e2c7fa27f0de89fbaa84d2 /src/core
parent777b019c7338b6a67f639bb86b90711055709c53 (diff)
downloadnginx-6a07833d478a9b969dfa8a66041fc8537ee2b8d1.tar.gz
nginx-6a07833d478a9b969dfa8a66041fc8537ee2b8d1.tar.bz2
ngx_hash_strlow()
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ngx_hash.c25
-rw-r--r--src/core/ngx_hash.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c
index c39395c7b..2954266ae 100644
--- a/src/core/ngx_hash.c
+++ b/src/core/ngx_hash.c
@@ -620,6 +620,24 @@ ngx_hash_key_lc(u_char *data, size_t len)
}
+ngx_uint_t
+ngx_hash_strlow(u_char *dst, u_char *src, size_t n)
+{
+ ngx_uint_t key;
+
+ key = 0;
+
+ while (n--) {
+ *dst = ngx_tolower(*src);
+ key = ngx_hash(key, *dst);
+ dst++;
+ src++;
+ }
+
+ return key;
+}
+
+
ngx_int_t
ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type)
{
@@ -794,12 +812,7 @@ wildcard:
/* wildcard hash */
- k = 0;
-
- for (i = skip; i < last; i++) {
- key->data[i] = ngx_tolower(key->data[i]);
- k = ngx_hash(k, key->data[i]);
- }
+ k = ngx_hash_strlow(&key->data[skip], &key->data[skip], last - skip);
k %= ha->hsize;
diff --git a/src/core/ngx_hash.h b/src/core/ngx_hash.h
index 95e04046f..76e3c774e 100644
--- a/src/core/ngx_hash.h
+++ b/src/core/ngx_hash.h
@@ -110,6 +110,8 @@ ngx_int_t ngx_hash_wildcard_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names,
#define ngx_hash(key, c) ((ngx_uint_t) key * 31 + c)
ngx_uint_t ngx_hash_key(u_char *data, size_t len);
ngx_uint_t ngx_hash_key_lc(u_char *data, size_t len);
+ngx_uint_t ngx_hash_strlow(u_char *dst, u_char *src, size_t n);
+
ngx_int_t ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type);
ngx_int_t ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key,