I doubt that block of code would cause performance issues regardless if you use a goto or not.
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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.
Last edited by cboard_member; 10-04-2007 at 01:18 PM.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
>> 3\n
>> Something else\n
Am I missing something ... ?
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
That's a big bump :\
Nothing a goto couldn't fix
Code:/* ... */ defualt: printf("Something else\n"); break; default: goto defualt; break; } /* ... */
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!Originally Posted by Rule #5