Raised This Month: $170 Target: $400

[SOLVED] IF Performance (Yeah, IF)

Post New Thread Reply   
Thread Tools Display Modes
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
maqi is offline
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-15-2018 , 02:40   Re: [SOLVED] IF Performance (Yeah, IF)
Reply With Quote #12

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

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

Thread Tools
Display Modes

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 16:09.

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