From 991610d33fcf4a8bf9ece30967f3326cfa555c1c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 15 Mar 2014 08:03:57 +0100 Subject: [PATCH] MEDIUM: stick-table: lookup table names using trees. This will speed up config parsing time when many stick-table references are used, as well as stick-table manipulations from the CLI. --- src/stick_table.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/stick_table.c b/src/stick_table.c index 9a3e855a13..92c4dd44cc 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -716,9 +716,15 @@ int stktable_get_data_type(char *name) struct proxy *find_stktable(const char *name) { struct proxy *px; + struct ebpt_node *node; - for (px = proxy; px; px = px->next) { - if (px->table.size && strcmp(px->id, name) == 0) + for (node = ebis_lookup(&proxy_by_name, name); node; node = ebpt_next(node)) { + px = container_of(node, struct proxy, conf.by_name); + + if (strcmp(px->id, name) != 0) + break; + + if (px->table.size) return px; } return NULL; -- 2.47.3