Raised This Month: $ Target: $400
 0% 

Code Style


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
issen1
Member
Join Date: Jan 2010
Old 10-16-2010 , 16:27   Re: Code Style
Reply With Quote #8

Quote:
Originally Posted by Firippu View Post
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.
__________________
greets (:
issen1 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode