]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
kmod_search_moddep: reorder to avoid creating path when not required.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 10 Dec 2011 11:26:27 +0000 (09:26 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 10 Dec 2011 11:26:27 +0000 (09:26 -0200)
if we're using mmap'ed index, say so and avoid creating the path as it
won't be used.

libkmod/libkmod.c

index 2a4c06055a3777d9e9ff582f63797d81c46a81a8..a41517e6911822b2672075f917b8339e16de09b2 100644 (file)
@@ -426,14 +426,17 @@ char *kmod_search_moddep(struct kmod_ctx *ctx, const char *name)
        char fn[PATH_MAX];
        char *line;
 
+       if (ctx->indexes[KMOD_INDEX_DEP]) {
+               DBG(ctx, "use mmaped index '%s' modname=%s\n",
+                       index_files[KMOD_INDEX_DEP], name);
+               return index_mm_search(ctx->indexes[KMOD_INDEX_DEP], name);
+       }
+
        snprintf(fn, sizeof(fn), "%s/%s.bin", ctx->dirname,
                                                index_files[KMOD_INDEX_DEP]);
 
        DBG(ctx, "file=%s modname=%s\n", fn, name);
 
-       if (ctx->indexes[KMOD_INDEX_DEP])
-               return index_mm_search(ctx->indexes[KMOD_INDEX_DEP], name);
-
        idx = index_file_open(fn);
        if (idx == NULL) {
                ERR(ctx, "Could not open moddep file '%s'", fn);