Quote:
Originally Posted by Firippu
However, if you wanted to execute more code after it, regardless if headshot is true or false, you would have to use method 2 or else it wouldn't reach it, unless headshot was false. Method 2 is more flexible, not more efficient.
|
You could write the code twice. Once in the if scope and once after. This shouldn't affect the efficiency, but sucks at maintaining, because you always need to edit the code twice, if you are changing something.
Quote:
|
Originally Posted by Exolent
Actually, method #2 is a bit more efficient because it would only use 1 return statement at the end, if it used one.
Method #1 would use several return statements.
|
Sounds like bullshit to me. You can't have several return statements in a function call (actually you can, in assembler, but this doesn't matter here).
Quote:
|
Originally Posted by Exolent
When these are put into the assembly code, method #1 has many jumps which could be avoided by using method #2.
I don't remember where this was discussed or who said it, though.
|
Any example? How will the flow of code be changed without the necessary jumps?
Actually I _think_ there is one compare and jump for each if-clause. But to be sure I will confirm this later while looking into the decompiled assembly.
__________________