[Message Deleted]
-
[Message Deleted]
-
[Message Deleted]
Is exiting the function right away will provide less memory movement Don't worry about that. Worry about code readability - and in this case exiting early wins hands down. Tomasz Sowinski -- http://www.shooltz.com
-
[Message Deleted]
Chances are it makes no difference which version you use, as probably the compiler redirects all returns inside a function to the same code stub. Anyway, you can always try to run a profile batch against your program to know (your VC++ comes with a profiler tool). From the point of view of readability, my opinion is (in accordance with what others have said) that the first version is better: When you finally got to the main part of code all secondary scenarios are ruled out, and that makes it easier to concentrate on a smaller mental model of your problem. That's how my brain works at least. I guess this could make for an interesting discussion subject at the lounge. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Chances are it makes no difference which version you use, as probably the compiler redirects all returns inside a function to the same code stub. Anyway, you can always try to run a profile batch against your program to know (your VC++ comes with a profiler tool). From the point of view of readability, my opinion is (in accordance with what others have said) that the first version is better: When you finally got to the main part of code all secondary scenarios are ruled out, and that makes it easier to concentrate on a smaller mental model of your problem. That's how my brain works at least. I guess this could make for an interesting discussion subject at the lounge. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
[Message Deleted]
-
[Message Deleted]
second option generates a higher jump value than the first one So what? How many nanoseconds do you want to save? I think you're wasting your time on totally irrelevant stuff. Tomasz Sowinski -- http://www.shooltz.com
-
second option generates a higher jump value than the first one So what? How many nanoseconds do you want to save? I think you're wasting your time on totally irrelevant stuff. Tomasz Sowinski -- http://www.shooltz.com
[Message Deleted]
-
[Message Deleted]
In a 3d engine, nothing is Irrelevant when it's about optimization Bullshit. In function like this you're checking if file exists. This means you have to call underlying OS, which usually causes context switch. This operation alone takes orders of magnitude longer than time saved with possible 'optimization' after rearranging control flow. As Michael Abrash writes in his "Graphics Programming Black Book": Know when it matters. (identify the portions of your program where peformance matters, and don't waste your time optimizing the rest. Tomasz Sowinski -- http://www.shooltz.com
-
In a 3d engine, nothing is Irrelevant when it's about optimization Bullshit. In function like this you're checking if file exists. This means you have to call underlying OS, which usually causes context switch. This operation alone takes orders of magnitude longer than time saved with possible 'optimization' after rearranging control flow. As Michael Abrash writes in his "Graphics Programming Black Book": Know when it matters. (identify the portions of your program where peformance matters, and don't waste your time optimizing the rest. Tomasz Sowinski -- http://www.shooltz.com
[Message Deleted]
-
[Message Deleted]
But let say this function is called every cycle Are we still talking about bmpLoader function? Do you suggest that you'll be loading bitmaps from disk in tight, time-critical loop? Tomasz Sowinski -- http://www.shooltz.com