From af9aeee7525dc30121e29176671751d506520af8 Mon Sep 17 00:00:00 2001 From: Wenfeng Liu Date: Fri, 5 Aug 2016 09:56:15 +0000 Subject: [PATCH] 1. Modify genlibtokenlookup.py to remove redundant header comparisons. 2. Remove inline qualifier of lookup_token() in genlibtokenlookup.py. --- genlibtokenlookup.py | 5 +++-- lib/nghttp2_hd.c | 27 --------------------------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/genlibtokenlookup.py b/genlibtokenlookup.py index e0726c59..a20efd69 100755 --- a/genlibtokenlookup.py +++ b/genlibtokenlookup.py @@ -88,7 +88,8 @@ def build_header(headers): c = k[-1] if c not in ent: ent[c] = [] - ent[c].append(k) + if k not in ent[c]: + ent[c].append(k) return res @@ -106,7 +107,7 @@ def gen_enum(): def gen_index_header(): print '''\ -static inline int32_t lookup_token(const uint8_t *name, size_t namelen) { +static int32_t lookup_token(const uint8_t *name, size_t namelen) { switch (namelen) {''' b = build_header(HEADERS) for size in sorted(b.keys()): diff --git a/lib/nghttp2_hd.c b/lib/nghttp2_hd.c index a02ef83a..d12e0b0b 100644 --- a/lib/nghttp2_hd.c +++ b/lib/nghttp2_hd.c @@ -183,9 +183,6 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { } break; case 'h': - if (lstreq(":pat", name, 4)) { - return NGHTTP2_TOKEN__PATH; - } if (lstreq(":pat", name, 4)) { return NGHTTP2_TOKEN__PATH; } @@ -222,17 +219,11 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { case 7: switch (name[6]) { case 'd': - if (lstreq(":metho", name, 6)) { - return NGHTTP2_TOKEN__METHOD; - } if (lstreq(":metho", name, 6)) { return NGHTTP2_TOKEN__METHOD; } break; case 'e': - if (lstreq(":schem", name, 6)) { - return NGHTTP2_TOKEN__SCHEME; - } if (lstreq(":schem", name, 6)) { return NGHTTP2_TOKEN__SCHEME; } @@ -251,24 +242,6 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { } break; case 's': - if (lstreq(":statu", name, 6)) { - return NGHTTP2_TOKEN__STATUS; - } - if (lstreq(":statu", name, 6)) { - return NGHTTP2_TOKEN__STATUS; - } - if (lstreq(":statu", name, 6)) { - return NGHTTP2_TOKEN__STATUS; - } - if (lstreq(":statu", name, 6)) { - return NGHTTP2_TOKEN__STATUS; - } - if (lstreq(":statu", name, 6)) { - return NGHTTP2_TOKEN__STATUS; - } - if (lstreq(":statu", name, 6)) { - return NGHTTP2_TOKEN__STATUS; - } if (lstreq(":statu", name, 6)) { return NGHTTP2_TOKEN__STATUS; }