MINOR: dict: Store the length of the dictionary entries.

When allocating new dictionary entries we store the length of the strings.
May be useful so that not to have to call strlen() too much often at runing
time.
This commit is contained in:
Frdric Lcaille 2019-06-07 10:58:20 +02:00 committed by Willy Tarreau
parent fdfa9e39ed
commit 99de1d0479
2 changed files with 3 additions and 0 deletions

View File

@ -7,6 +7,7 @@
struct dict_entry { struct dict_entry {
struct ebpt_node value; struct ebpt_node value;
unsigned int refcount; unsigned int refcount;
size_t len;
}; };
struct dict { struct dict {

View File

@ -36,6 +36,7 @@ static struct dict_entry *new_dict_entry(char *s)
if (!de->value.key) if (!de->value.key)
goto err; goto err;
de->len = strlen(s);
de->refcount = 1; de->refcount = 1;
return de; return de;
@ -43,6 +44,7 @@ static struct dict_entry *new_dict_entry(char *s)
err: err:
free(de->value.key); free(de->value.key);
de->value.key = NULL; de->value.key = NULL;
de->len = 0;
free(de); free(de);
return NULL; return NULL;
} }