mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
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:
parent
fdfa9e39ed
commit
99de1d0479
@ -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 {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user