diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-04-01 22:25:24 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-04-03 19:41:02 +0200 |
commit | 31a57f195f1cda03741a18c3393b7bebddaacf1c (patch) | |
tree | ac8b1e69b5a3c338a3495b2ed5f162cace7848e1 /src/evaluate.c | |
parent | a3ac2527724dd27628e12caaa55f731b109e4586 (diff) |
evaluate: use chain hashtable for lookups
Instead of the linear list lookup.
Before this patch:
real 0m21,735s
user 0m20,329s
sys 0m1,384s
After:
real 0m10,910s
user 0m9,448s
sys 0m1,434s
chain_lookup() is removed since linear list lookups are only used by the
fuzzy chain name matching for error reporting.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r-- | src/evaluate.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index 8105d8d5..50f100db 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -4109,14 +4109,14 @@ static int chain_evaluate(struct eval_ctx *ctx, struct chain *chain) return table_not_found(ctx); if (chain == NULL) { - if (chain_lookup(table, &ctx->cmd->handle) == NULL) { + if (chain_cache_find(table, &ctx->cmd->handle) == NULL) { chain = chain_alloc(NULL); handle_merge(&chain->handle, &ctx->cmd->handle); chain_cache_add(chain, table); } return 0; } else if (!(chain->flags & CHAIN_F_BINDING)) { - if (chain_lookup(table, &chain->handle) == NULL) + if (chain_cache_find(table, &chain->handle) == NULL) chain_cache_add(chain_get(chain), table); } @@ -4443,7 +4443,7 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) if (table == NULL) return table_not_found(ctx); - if (chain_lookup(table, &cmd->handle) == NULL) + if (chain_cache_find(table, &cmd->handle) == NULL) return chain_not_found(ctx); return 0; @@ -4603,7 +4603,7 @@ static int cmd_evaluate_rename(struct eval_ctx *ctx, struct cmd *cmd) if (table == NULL) return table_not_found(ctx); - if (chain_lookup(table, &ctx->cmd->handle) == NULL) + if (chain_cache_find(table, &ctx->cmd->handle) == NULL) return chain_not_found(ctx); break; |