From: Gustavo Sverzut Barbieri Date: Sat, 10 Dec 2011 11:26:27 +0000 (-0200) Subject: kmod_search_moddep: reorder to avoid creating path when not required. X-Git-Tag: v1~55^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85132101e456f194b2190eadb7ff8b3078fcd228;p=thirdparty%2Fkmod.git kmod_search_moddep: reorder to avoid creating path when not required. if we're using mmap'ed index, say so and avoid creating the path as it won't be used. --- diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 2a4c0605..a41517e6 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -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);