I was looking through the TimSort java code: Original Source
in particular lines 676 to 739 of the mergeLo function. It has (roughly) the following layout:
outer:
while (true) {
//Code here
break outer; //Code within a few if tests in the loop.
}
//Code here executes somehow.
I am confused as to how this function could ever stop running, because the only break statements go to the outer block (which should then fall back into the while(true), and there are no return statements.
My problem is that line 747 is executing and throwing an exception when I try and sort 184 or more elements, and I want to figure out how to fix it, any help would be greatly appreciated.
[Note]: This is the function being called by the collections.sort method for Java deployed on an android phone.
The label ‘outer’ is just an alias for the while loop. That is, the break statement breaks the loop and the control flow continues after the loop.
In contrast, continue outer would return to the top of the while loop.