From: Willy Tarreau Date: Sun, 15 Sep 2024 21:40:59 +0000 (+0200) Subject: OPTIM: vars: inline vars_prune() to avoid many calls X-Git-Tag: v3.1-dev8~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c1a9c3a4315a589fdd202b3ab7cf2e25bbdfaa7;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/vars.h b/include/haproxy/vars.h index b66a5d4412..641fba2745 100644 --- a/include/haproxy/vars.h +++ b/include/haproxy/vars.h @@ -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 diff --git a/src/vars.c b/src/vars.c index 772ae34022..f7d12e8484 100644 --- a/src/vars.c +++ b/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 . */