Search dynamic table first for optimization
This commit is contained in:
parent
16c46114dc
commit
60cae325bc
|
@ -532,7 +532,7 @@ static void hd_map_insert(nghttp2_hd_map *map, nghttp2_hd_entry *ent) {
|
||||||
|
|
||||||
static nghttp2_hd_entry *hd_map_find(nghttp2_hd_map *map, int *exact_match,
|
static nghttp2_hd_entry *hd_map_find(nghttp2_hd_map *map, int *exact_match,
|
||||||
const nghttp2_nv *nv, int32_t token,
|
const nghttp2_nv *nv, int32_t token,
|
||||||
uint32_t hash) {
|
uint32_t hash, int name_only) {
|
||||||
nghttp2_hd_entry *p;
|
nghttp2_hd_entry *p;
|
||||||
nghttp2_hd_entry *res = NULL;
|
nghttp2_hd_entry *res = NULL;
|
||||||
|
|
||||||
|
@ -545,6 +545,9 @@ static nghttp2_hd_entry *hd_map_find(nghttp2_hd_map *map, int *exact_match,
|
||||||
}
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
res = p;
|
res = p;
|
||||||
|
if (name_only) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (value_eq(&p->nv, nv)) {
|
if (value_eq(&p->nv, nv)) {
|
||||||
res = p;
|
res = p;
|
||||||
|
@ -1148,16 +1151,16 @@ static int add_hd_table_incremental(nghttp2_hd_context *context,
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ssize_t index;
|
ssize_t index;
|
||||||
/* Nonzero if both name and value are matched. */
|
/* Nonzero if both name and value are matched. */
|
||||||
uint8_t name_value_match;
|
int name_value_match;
|
||||||
} search_result;
|
} search_result;
|
||||||
|
|
||||||
static search_result search_static_table(const nghttp2_nv *nv, int32_t token,
|
static search_result search_static_table(const nghttp2_nv *nv, int32_t token,
|
||||||
int indexing_mode) {
|
int name_only) {
|
||||||
search_result res = {token, 0};
|
search_result res = {token, 0};
|
||||||
int i;
|
int i;
|
||||||
nghttp2_hd_static_entry *ent;
|
nghttp2_hd_static_entry *ent;
|
||||||
|
|
||||||
if (indexing_mode == NGHTTP2_HD_NEVER_INDEXING) {
|
if (name_only) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,30 +1185,22 @@ static search_result search_hd_table(nghttp2_hd_context *context,
|
||||||
search_result res = {-1, 0};
|
search_result res = {-1, 0};
|
||||||
nghttp2_hd_entry *ent;
|
nghttp2_hd_entry *ent;
|
||||||
int exact_match;
|
int exact_match;
|
||||||
|
int name_only = indexing_mode == NGHTTP2_HD_NEVER_INDEXING;
|
||||||
if (token >= 0 && token <= NGHTTP2_TOKEN_WWW_AUTHENTICATE) {
|
|
||||||
res = search_static_table(nv, token, indexing_mode);
|
|
||||||
if (res.name_value_match) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exact_match = 0;
|
exact_match = 0;
|
||||||
ent = hd_map_find(map, &exact_match, nv, token, hash);
|
ent = hd_map_find(map, &exact_match, nv, token, hash, name_only);
|
||||||
if (ent == NULL) {
|
|
||||||
return res;
|
if (!exact_match && token >= 0 && token <= NGHTTP2_TOKEN_WWW_AUTHENTICATE) {
|
||||||
|
return search_static_table(nv, token, name_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.index != -1 && !exact_match) {
|
if (ent == NULL) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.index =
|
res.index =
|
||||||
(ssize_t)(context->next_seq - 1 - ent->seq + NGHTTP2_STATIC_TABLE_LENGTH);
|
(ssize_t)(context->next_seq - 1 - ent->seq + NGHTTP2_STATIC_TABLE_LENGTH);
|
||||||
|
res.name_value_match = exact_match;
|
||||||
if (exact_match) {
|
|
||||||
res.name_value_match = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue