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:
parent
fd8ed7554e
commit
25236a963f
@ -1184,10 +1184,29 @@ 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++;
|
||||
|
||||
if (cmd->ro_count || cmd->any_ro_count)
|
||||
command_names_args[cn].variant_has_ro = 1;
|
||||
if (cmd->rp_count)
|
||||
command_names_args[cn].variant_has_rp = 1;
|
||||
if (cmd->oo_count)
|
||||
command_names_args[cn].variant_has_oo = 1;
|
||||
if (cmd->op_count)
|
||||
command_names_args[cn].variant_has_op = 1;
|
||||
|
||||
for (ro = 0; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
|
||||
command_names_args[cn].all_options[cmd->required_opt_args[ro].opt] = 1;
|
||||
|
||||
if ((cmd->required_opt_args[ro].opt == size_ARG) && !strncmp(cmd->name, "lv", 2))
|
||||
command_names_args[cn].all_options[extents_ARG] = 1;
|
||||
}
|
||||
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++) {
|
||||
@ -1198,26 +1217,7 @@ void factor_common_options(void)
|
||||
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;
|
||||
if (cmd->rp_count)
|
||||
command_names_args[cn].variant_has_rp = 1;
|
||||
if (cmd->oo_count)
|
||||
command_names_args[cn].variant_has_oo = 1;
|
||||
if (cmd->op_count)
|
||||
command_names_args[cn].variant_has_op = 1;
|
||||
|
||||
for (ro = 0; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
|
||||
command_names_args[cn].all_options[cmd->required_opt_args[ro].opt] = 1;
|
||||
|
||||
if ((cmd->required_opt_args[ro].opt == size_ARG) && !strncmp(cmd->name, "lv", 2))
|
||||
command_names_args[cn].all_options[extents_ARG] = 1;
|
||||
}
|
||||
for (oo = 0; oo < cmd->oo_count; oo++)
|
||||
command_names_args[cn].all_options[cmd->optional_opt_args[oo].opt] = 1;
|
||||
|
||||
found = 0;
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
if (cmd->optional_opt_args[oo].opt == opt_enum) {
|
||||
found = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user