]> git.kaiwu.me - nginx.git/commitdiff
HTTP/2: precalculate hash for "Cookie".
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 15 Feb 2018 16:06:22 +0000 (19:06 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 15 Feb 2018 16:06:22 +0000 (19:06 +0300)
There is no need to calculate hashes of static strings at runtime.  The
ngx_hash() macro can be used to do it during compilation instead, similarly
to how it is done in ngx_http_proxy_module.c for "Server" and "Date" headers.

src/http/v2/ngx_http_v2.c

index 44d01107a2e339258868e1599012e78cd9653f43..7bea204fcfe79b6ceaae348f7c52e88e763e092d 100644 (file)
@@ -3698,7 +3698,8 @@ ngx_http_v2_construct_cookie_header(ngx_http_request_t *r)
         return NGX_ERROR;
     }
 
-    h->hash = ngx_hash_key(cookie.data, cookie.len);
+    h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash(
+                                    ngx_hash('c', 'o'), 'o'), 'k'), 'i'), 'e');
 
     h->key.len = cookie.len;
     h->key.data = cookie.data;