]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: vars: inline vars_prune() to avoid many calls
authorWilly Tarreau <w@1wt.eu>
Sun, 15 Sep 2024 21:40:59 +0000 (23:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 15 Sep 2024 21:42:09 +0000 (23:42 +0200)
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.

include/haproxy/vars.h
src/vars.c

index b66a5d4412bee8ea7adbfa928892ec339d4d7ba5..641fba2745f9b0fbe0f3d29333f467226b9c2658 100644 (file)
@@ -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
index 772ae340224c7feb6e08825ca46461a0116fbdf2..f7d12e84846cb8c99181df1749800c5efff4cf7b 100644 (file)
@@ -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>.
  */