]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Optimize nl_cache_ops_associate by checking protocol early
authorThomas Graf <tgr@deb.localdomain>
Wed, 5 Mar 2008 13:11:05 +0000 (14:11 +0100)
committerThomas Graf <tgr@deb.localdomain>
Wed, 5 Mar 2008 13:11:05 +0000 (14:11 +0100)
lib/cache_mngt.c

index de2bf243409d404a8430d213a3b1128c70a311cd..137d6c92e17c2d7580e6a6f72ccd63cc80f6f547 100644 (file)
@@ -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;
 }