From: Frédéric Lécaille Date: Fri, 7 Jun 2019 08:58:20 +0000 (+0200) Subject: MINOR: dict: Store the length of the dictionary entries. X-Git-Tag: v2.0-dev7~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99de1d0479c35229acf01feeabfe4e7c8c3dd7da;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/types/dict.h b/include/types/dict.h index 9e4f41a68b..006e91524d 100644 --- a/include/types/dict.h +++ b/include/types/dict.h @@ -7,6 +7,7 @@ struct dict_entry { struct ebpt_node value; unsigned int refcount; + size_t len; }; struct dict { diff --git a/src/dict.c b/src/dict.c index 777530a20c..c2580e1793 100644 --- a/src/dict.c +++ b/src/dict.c @@ -36,6 +36,7 @@ static struct dict_entry *new_dict_entry(char *s) if (!de->value.key) goto err; + de->len = strlen(s); de->refcount = 1; return de; @@ -43,6 +44,7 @@ static struct dict_entry *new_dict_entry(char *s) err: free(de->value.key); de->value.key = NULL; + de->len = 0; free(de); return NULL; }