Skip to content

I20210413-1400

tagged this 13 Apr 06:55
Merge consecutive if statements with same code block that end with a
jump statement:

Given:
        if (i1 == 0) {
            System.out.println("The same code");
            return;
        }
        if (i1 == 1) {
            System.out.println("The same code");
            return;
        }
        System.out.println("Next code");

When:
Applying "One if rather than duplicate blocks that fall through" clean
up...

Then:
        if ((i1 == 0) || (i1 == 1)) {
            System.out.println("The same code");
            return;
        }
        System.out.println("Next code");

Change-Id: I94d94c3f1bb101f74a10d320baff0ae3a938a4d6
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Assets 2
Loading