]> git.kaiwu.me - haproxy.git/commitdiff
OPTIM: pattern: use ebst_lookup_len() when possible
authorWilly Tarreau <w@1wt.eu>
Mon, 30 Nov 2026 19:49:54 +0000 (20:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 1 Dec 2026 07:17:13 +0000 (08:17 +0100)
In pat_match_str(), we're looking up strings using ebst_lookup(),
but we know the length and already have ebst_lookup_len() that is
made for this purpose, so better rely on it since it's a bit faster.
This speeds up request rate by 1% on configs with a few tens of
string lookups.

src/pattern.c

index 0f95eeae73052bd750e49c46df4e30702d6bb3b8..00042417837c50d3807d109d8580cd5722c9ef67 100644 (file)
@@ -506,7 +506,7 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
                if (!pat_match_ensure_str(smp))
                        return NULL;
 
-               node = ebst_lookup(&expr->pattern_tree, smp->data.u.str.area);
+               node = ebst_lookup_len(&expr->pattern_tree, smp->data.u.str.area, smp->data.u.str.data);
 
                while (node) {
                        elt = ebmb_entry(node, struct pattern_tree, node);