If I have a while loop with a for loop inside of the while loop, how can I break both loops?
I’m doing this because the extra 250ms I get from not completing these loops after I found what I want adds up to be valuable after a while.
pseudocode:
while(alwaysTrue) {
for(NSArray *arr in twoThousandItems) {
if(IFoundWhatIWasLookingFor) {
// assign some stuff here
// break everything, not just the for loop.
}
}
}
This is where
gotois your friend. Yes, thatgoto.The other option is to have short circuits in your loops.