On Mon, Jul 18, 2016 at 10:25:25AM -0300, Eduardo Lima (Etrunko) wrote: > Use switch/case instead of lots of conditional blocks > > Signed-off-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx> > --- > src/ovirt-foreign-menu.c | 41 +++++++++++++++-------------------------- > 1 file changed, 15 insertions(+), 26 deletions(-) > > diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c > index 33ff4f1..80e40a1 100644 > --- a/src/ovirt-foreign-menu.c > +++ b/src/ovirt-foreign-menu.c > @@ -312,51 +312,40 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, > g_return_if_fail(current_state >= STATE_0); > g_return_if_fail(current_state < STATE_ISOS); > > - current_state++; > - > - if (current_state == STATE_API) { > + switch (++current_state) { > + case STATE_API: > if (menu->priv->api == NULL) { > ovirt_foreign_menu_fetch_api_async(menu); > - } else { > - current_state++; > + break; > } > - } > - > - if (current_state == STATE_VM) { > + case STATE_VM: > if (menu->priv->vm == NULL) { > ovirt_foreign_menu_fetch_vm_async(menu); > - } else { > - current_state++; > + break; > } I'd add some comment every time we fall through to the next state, otherwise it can be confusing as there is a break; statement, but in a conditional. Christophe
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list