From 358e44efa4b6791943acd26d4f9ad85771c6830c Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 5 Mar 2008 14:11:05 +0100 Subject: [PATCH] Optimize nl_cache_ops_associate by checking protocol early --- lib/cache_mngt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/cache_mngt.c b/lib/cache_mngt.c index de2bf24..137d6c9 100644 --- a/lib/cache_mngt.c +++ b/lib/cache_mngt.c @@ -60,11 +60,14 @@ struct nl_cache_ops *nl_cache_ops_associate(int protocol, int msgtype) int i; struct nl_cache_ops *ops; - for (ops = cache_ops; ops; ops = ops->co_next) + for (ops = cache_ops; ops; ops = ops->co_next) { + if (ops->co_protocol != protocol) + continue; + for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++) - if (ops->co_msgtypes[i].mt_id == msgtype && - ops->co_protocol == protocol) + if (ops->co_msgtypes[i].mt_id == msgtype) return ops; + } return NULL; }