[SOLVED] IF Performance (Yeah, IF)
Code:
public FMVoiceSetClientListening(Recv,Sender,bool:Listen) Code:
public FMVoiceSetClientListening(Recv,Sender,bool:Listen) Because if first check is false, the plugin will not call other (sub) checks At second example same if is calling both functions at same time. Someone more skilled than me can sane this doubt? Thanks again |
Re: IF Performance (Yeah, IF)
If you have multiple AND's chained, than if the first expression is false, the compiler won't check the others.
|
Re: IF Performance (Yeah, IF)
Exactly, as far as i know, if you are chaining AND's, it goes left to right, as soon as one is false, it won't check further. For OR's it won't check the others as soon as one is true.
Following that logic the thing you should look out for, is how likely an expression is to be true, place the less likely ones up front :D But anyway i think that the performance gain from this is minimal, but good practice. |
Re: IF Performance (Yeah, IF)
Quote:
@maqi I doubt that in execution time the plugin will not continue checking before first check fail since it in same line. Also i guess performance is relative that what is calling the function (How many times) / frame or second for example. Lets see other users to have sure |
Re: IF Performance (Yeah, IF)
That is exactly what im saying, i could be wrong, but i was always thought like this, I just wanted to pass it on.
|
Re: IF Performance (Yeah, IF)
I tried to check pawn documentation, but this not explain nothing :|
I will use FIRST example to have sure |
Re: IF Performance (Yeah, IF)
They will probably compile to same bytecode (or with little differences that won't matter to performance). What Maqi said is true and that phenomenon is called "short-circuit evaluation".
|
Re: IF Performance (Yeah, IF)
Quote:
|
Re: IF Performance (Yeah, IF)
Quote:
|
Re: [SOLVED] IF Performance (Yeah, IF)
I like more with return values, but that's doesn't matter if you do not do wrong.
Code:
|
All times are GMT -4. The time now is 19:26. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.