1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

command: refactor inner loop

Move part of the 'inner' loop which is would be otherwise
always production same results for all  'opt_enum' values
out of the loop, so it can be evaluated just once.
This commit is contained in:
Zdenek Kabelac 2024-05-12 18:29:31 +02:00
parent fd8ed7554e
commit 25236a963f

View File

@ -1184,19 +1184,11 @@ void factor_common_options(void)
for (ci = 0; ci < COMMAND_COUNT; ci++) {
cmd = &commands[ci];
if (cmd->lvm_command_enum != command_names[cn].lvm_command_enum)
continue;
command_names_args[cn].variants++;
}
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
for (ci = 0; ci < COMMAND_COUNT; ci++) {
cmd = &commands[ci];
if (cmd->lvm_command_enum != command_names[cn].lvm_command_enum)
continue;
if (cmd->ro_count || cmd->any_ro_count)
command_names_args[cn].variant_has_ro = 1;
@ -1215,9 +1207,17 @@ void factor_common_options(void)
}
for (oo = 0; oo < cmd->oo_count; oo++)
command_names_args[cn].all_options[cmd->optional_opt_args[oo].opt] = 1;
}
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
for (ci = 0; ci < COMMAND_COUNT; ci++) {
cmd = &commands[ci];
if (cmd->lvm_command_enum != command_names[cn].lvm_command_enum)
continue;
found = 0;
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt == opt_enum) {
found = 1;