]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] acl: provide the argument length for fetch functions
authorWilly Tarreau <w@1wt.eu>
Sun, 10 Jun 2007 09:17:01 +0000 (11:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 10 Jun 2007 09:17:01 +0000 (11:17 +0200)
Some fetch() functions will require an argument (eg: header).
It's wise to provide the argument size to optimize string
comparisons.

include/types/acl.h
src/acl.c

index d67928897586a6f0a6401f88dfdcdbe0a89c73a2..0eecd335f0efb24bfbe4cfccd13313ea0e4df80a 100644 (file)
@@ -164,6 +164,7 @@ struct acl_expr {
        union {                     /* optional argument of the subject (eg: header or cookie name) */
                char *str;
        } arg;
+       int arg_len;                /* optional argument length */
        struct list patterns;       /* list of acl_patterns */
 };
 
index 4443ae9ade64a9d7bc718311fdf61f40358964c9..2cd154ca0d84afb2c04d02af018b55ed4029f020 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -435,6 +435,7 @@ struct acl_expr *parse_acl_expr(const char **args)
        aclkw->use_cnt++;
        LIST_INIT(&expr->patterns);
        expr->arg.str = NULL;
+       expr->arg_len = 0;
 
        arg = strchr(args[0], '(');
        if (arg != NULL) {
@@ -449,6 +450,7 @@ struct acl_expr *parse_acl_expr(const char **args)
                        goto out_free_expr;
                memcpy(arg2, arg, end - arg);
                arg2[end-arg] = '\0';
+               expr->arg_len = end - arg;
                expr->arg.str = arg2;
        }