Raised This Month: $51 Target: $400
 12% 

[SOLVED] IF Performance (Yeah, IF)


Post New Thread Reply   
 
Thread Tools Display Modes
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-14-2018 , 21:30   Re: [SOLVED] IF Performance (Yeah, IF)
Reply With Quote #11

I prefer the crazy way too xD
__________________
stuff
maqi is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-15-2018 , 02:40   Re: [SOLVED] IF Performance (Yeah, IF)
Reply With Quote #12

Quote:
Originally Posted by CrazY. View Post
I like more with return values, but that's doesn't matter if you do not do wrong.

Code:
public FMVoiceSetClientListening(Recv,Sender,bool:Listen) {     if (Recv == Sender)         return FMRES_IGNORED;     if (!is_user_connected(Recv) || !is_user_connected(Sender))         return FMRES_IGNORED;     if (get_user_team(Recv) != get_user_team(Sender))         return FMRES_IGNORED;         engfunc(EngFunc_SetClientListening,Recv,Sender,true);     return FMRES_SUPERCEDE; }
I believe this is considered the best practice - check your cases early and return, makes it easy to follow the "main" path of the code and keeps the indentation low.
__________________
klippy is offline
Reply



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 06:14.


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