I have the following code (This is partially pseudo code for demonstration):
void foo(...){
//some code here
do{
min_item = _MAX_VALUE;
//some code here also
if (min_item == _MAX_VALUE)
break;
if (smaller_item_x == min_item){
FIRST_IS_SMALLER:
global_queue[size++] = smaller_item_x;
if (next_item_x!=0){
smaller_item_x= next_item_x;
if (smaller_item_x > smaller_item_y)
goto SECOND_IS_SMALLER;
}
}else{
SECOND_IS_SMALLER:
global_queue[size++] = smaller_item_y;
if (next_item_y!=0){
smaller_item_y= next_item_y;
if (smaller_item_y > smaller_item_x)
goto FIRST_IS_SMALLER;
}
}
}while(true)
As far as i know goto is translated to jmp in assembler, i am interested to increase performance of this procedure by changing the second goto to something similar to branch (shorter command with short jump up), i may be missing something, and it could be trivial, so my apologies.