modinfo: trivial optimizations

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-02-15 01:45:14 +01:00
parent 12f44ea183
commit df7f2008c2

View File

@ -44,7 +44,7 @@ static int display(const char *data, const char *pattern, int flag)
} }
static void modinfo(const char *path, const char *version, static void modinfo(const char *path, const char *version,
struct modinfo_env *env) const struct modinfo_env *env)
{ {
static const char *const shortcuts[] = { static const char *const shortcuts[] = {
"filename", "filename",
@ -82,11 +82,13 @@ static void modinfo(const char *path, const char *version,
if (field) if (field)
tags |= OPT_F; tags |= OPT_F;
for (j = 1; (1<<j) & (OPT_TAGS + OPT_F); j++) { for (j = 1; (1<<j) & (OPT_TAGS + OPT_F); j++) {
const char *pattern = field; const char *pattern;
if ((1<<j) & OPT_TAGS)
pattern = shortcuts[j];
if (!((1<<j) & tags)) if (!((1<<j) & tags))
continue; continue;
pattern = field;
if ((1<<j) & OPT_TAGS)
pattern = shortcuts[j];
length = strlen(pattern); length = strlen(pattern);
ptr = the_module; ptr = the_module;
while (1) { while (1) {