Structure Infinite Loop
- You have a jump to a previous label.
Make the intermediate statements the body of an infinite loop.
next: /* loop */ ... goto next;
⇓
while(1) { /* loop */ ... }
Motivation
Infinite loops are not frequently used by programmers, nevertheless, compilers often use these unconditional loops together with break and continue jumps to translate ordinary while and for loops. This refactoring recovers those original control structures as an intermediate step.
Mechanics
Make the set of skipped statements the body of the do-while statement.
- Remove the label, if no longer used.