Skip to content

Commit 2c1a9c3

Browse files
committed
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.
1 parent aad6b77 commit 2c1a9c3

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

include/haproxy/vars.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ struct arg;
3535
void vars_init_head(struct vars *vars, enum vars_scope scope);
3636
void var_accounting_diff(struct vars *vars, struct session *sess, struct stream *strm, int size);
3737
unsigned int var_clear(struct var *var, int force);
38-
void vars_prune(struct vars *vars, struct session *sess, struct stream *strm);
3938
void vars_prune_per_sess(struct vars *vars);
4039
int var_set(const struct var_desc *desc, struct sample *smp, uint flags);
4140
int var_unset(const struct var_desc *desc, struct sample *smp);
@@ -74,4 +73,19 @@ static inline void vars_rdunlock(struct vars *vars)
7473
HA_RWLOCK_RDUNLOCK(VARS_LOCK, &vars->rwlock);
7574
}
7675

76+
/* This function free all the memory used by all the variables
77+
* in the list.
78+
*/
79+
static inline void vars_prune(struct vars *vars, struct session *sess, struct stream *strm)
80+
{
81+
struct var *var, *tmp;
82+
unsigned int size = 0;
83+
84+
list_for_each_entry_safe(var, tmp, &vars->head, l) {
85+
size += var_clear(var, 1);
86+
}
87+
88+
var_accounting_diff(vars, sess, strm, -size);
89+
}
90+
7791
#endif

src/vars.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,6 @@ unsigned int var_clear(struct var *var, int force)
195195
return size;
196196
}
197197

198-
/* This function free all the memory used by all the variables
199-
* in the list.
200-
*/
201-
void vars_prune(struct vars *vars, struct session *sess, struct stream *strm)
202-
{
203-
struct var *var, *tmp;
204-
unsigned int size = 0;
205-
206-
list_for_each_entry_safe(var, tmp, &vars->head, l) {
207-
size += var_clear(var, 1);
208-
}
209-
210-
var_accounting_diff(vars, sess, strm, -size);
211-
}
212-
213198
/* This function frees all the memory used by all the session variables in the
214199
* list starting at <vars>.
215200
*/

0 commit comments

Comments
 (0)