Commit af9aeee7 authored by Wenfeng Liu's avatar Wenfeng Liu

1. Modify genlibtokenlookup.py to remove redundant header comparisons.

2. Remove inline qualifier of lookup_token() in genlibtokenlookup.py.
parent f619286c
...@@ -88,6 +88,7 @@ def build_header(headers): ...@@ -88,6 +88,7 @@ def build_header(headers):
c = k[-1] c = k[-1]
if c not in ent: if c not in ent:
ent[c] = [] ent[c] = []
if k not in ent[c]:
ent[c].append(k) ent[c].append(k)
return res return res
...@@ -106,7 +107,7 @@ def gen_enum(): ...@@ -106,7 +107,7 @@ def gen_enum():
def gen_index_header(): def gen_index_header():
print '''\ 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) {''' switch (namelen) {'''
b = build_header(HEADERS) b = build_header(HEADERS)
for size in sorted(b.keys()): for size in sorted(b.keys()):
......
...@@ -183,9 +183,6 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { ...@@ -183,9 +183,6 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) {
} }
break; break;
case 'h': case 'h':
if (lstreq(":pat", name, 4)) {
return NGHTTP2_TOKEN__PATH;
}
if (lstreq(":pat", name, 4)) { if (lstreq(":pat", name, 4)) {
return NGHTTP2_TOKEN__PATH; return NGHTTP2_TOKEN__PATH;
} }
...@@ -222,17 +219,11 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { ...@@ -222,17 +219,11 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) {
case 7: case 7:
switch (name[6]) { switch (name[6]) {
case 'd': case 'd':
if (lstreq(":metho", name, 6)) {
return NGHTTP2_TOKEN__METHOD;
}
if (lstreq(":metho", name, 6)) { if (lstreq(":metho", name, 6)) {
return NGHTTP2_TOKEN__METHOD; return NGHTTP2_TOKEN__METHOD;
} }
break; break;
case 'e': case 'e':
if (lstreq(":schem", name, 6)) {
return NGHTTP2_TOKEN__SCHEME;
}
if (lstreq(":schem", name, 6)) { if (lstreq(":schem", name, 6)) {
return NGHTTP2_TOKEN__SCHEME; return NGHTTP2_TOKEN__SCHEME;
} }
...@@ -251,24 +242,6 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) { ...@@ -251,24 +242,6 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) {
} }
break; break;
case 's': 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)) { if (lstreq(":statu", name, 6)) {
return NGHTTP2_TOKEN__STATUS; return NGHTTP2_TOKEN__STATUS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment