I doubt that block of code would cause performance issues regardless if you use a goto or not.
Printable View
I doubt that block of code would cause performance issues regardless if you use a goto or not.
There should be little difference betwenand the solution you posted. If there is, it's most likely because of the code generator in the compiler believes that the !WeCantSeeTheObject is not the same hit-rate as it really is (that is, the compiler is trying to optimize for a different rate of invisible objects than the code really has). But really, the code should be very close between those two cases.Code:if(!WeCantSeeTheObject()) {
... rendering code ...
}
gcc has a "predictor likelyhood" extension that can tell the compiler that something is likely or unlikely to he true - that way, the compiler can string together the likely variations in a straight line, and the unlikely ones out of line.
--
Mats
Going backwards can easily be handled.Code:int main()
{
mylab:;
goto mylab;
return 0;
}
Code:void goto_mylab() {
goto mylab; }
int main()
{
mylab:;
goto_mylab();
return 0;
}
Except you can't use goto to jump from one function to another.
When I used to use them before (I mean when I started), I used to amuse myself like so:
I used to have others that I can't remember now though.Code:int main( void ) {
/* blah */
hell:;
/* blah2 */
goto hell; // <- twomers amused
/* blah3 */
return 0;
}
What does this print, and why?
Code:#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main ( ) {
int a = 4;
switch ( a ) {
case 1: case 2:
printf("1 or 2\n" );
break;
case 3:
printf("3\n" );
break;
defualt:
printf("Something else\n");
break;
}
return 0;
}
Default is misspelt ... so it'll err.
3\n
Something else\n
I do believe.
EDIT: Wait... that's just stupid. Ignore that. It'll print nothing, right? ... I feel intensely retarded today.
EDIT2: Well I've set MSVC to flag warnings as errors, unreferenced label.
>> 3\n
>> Something else\n
Am I missing something ... ?
That's a big bump :\
Nothing a goto couldn't fix :)
Code:/* ... */
defualt:
printf("Something else\n");
break;
default:
goto defualt;
break;
}
/* ... */
Please don't bump old threads
Whats so bad about bumping old threads? As long as you arent harassing other people for attention that is.
Doesn't really matter why it's bad, but it does matter that it is bad :)
Naughty iMalc! :)Quote:
Originally Posted by Rule #5