OPTIM: vars: inline vars_prune() to avoid many calls
Many configs don't have variables and call it for no reason, and even configs with variables don't necessarily have some in all scopes.
This commit is contained in:
parent
aad6b771dd
commit
2c1a9c3a43
@ -35,7 +35,6 @@ struct arg;
|
||||
void vars_init_head(struct vars *vars, enum vars_scope scope);
|
||||
void var_accounting_diff(struct vars *vars, struct session *sess, struct stream *strm, int size);
|
||||
unsigned int var_clear(struct var *var, int force);
|
||||
void vars_prune(struct vars *vars, struct session *sess, struct stream *strm);
|
||||
void vars_prune_per_sess(struct vars *vars);
|
||||
int var_set(const struct var_desc *desc, struct sample *smp, uint flags);
|
||||
int var_unset(const struct var_desc *desc, struct sample *smp);
|
||||
@ -74,4 +73,19 @@ static inline void vars_rdunlock(struct vars *vars)
|
||||
HA_RWLOCK_RDUNLOCK(VARS_LOCK, &vars->rwlock);
|
||||
}
|
||||
|
||||
/* This function free all the memory used by all the variables
|
||||
* in the list.
|
||||
*/
|
||||
static inline void vars_prune(struct vars *vars, struct session *sess, struct stream *strm)
|
||||
{
|
||||
struct var *var, *tmp;
|
||||
unsigned int size = 0;
|
||||
|
||||
list_for_each_entry_safe(var, tmp, &vars->head, l) {
|
||||
size += var_clear(var, 1);
|
||||
}
|
||||
|
||||
var_accounting_diff(vars, sess, strm, -size);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
15
src/vars.c
15
src/vars.c
@ -195,21 +195,6 @@ unsigned int var_clear(struct var *var, int force)
|
||||
return size;
|
||||
}
|
||||
|
||||
/* This function free all the memory used by all the variables
|
||||
* in the list.
|
||||
*/
|
||||
void vars_prune(struct vars *vars, struct session *sess, struct stream *strm)
|
||||
{
|
||||
struct var *var, *tmp;
|
||||
unsigned int size = 0;
|
||||
|
||||
list_for_each_entry_safe(var, tmp, &vars->head, l) {
|
||||
size += var_clear(var, 1);
|
||||
}
|
||||
|
||||
var_accounting_diff(vars, sess, strm, -size);
|
||||
}
|
||||
|
||||
/* This function frees all the memory used by all the session variables in the
|
||||
* list starting at <vars>.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user