Raised This Month: $ Target: $400
 0% 

[SOLVED] How I can optimize this code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-14-2014 , 07:10   Re: [HELP] How I can optimize this code?
Reply With Quote #1

Quote:
Originally Posted by KliPPy View Post
And replace your function with this one:
This is probably the best solution. The only issue is that this code may set an invalid model if g_szModels[g_playercurweapon[id]] points to "" (such as for the C4). You should add an additional check for that.
__________________
In Flames we trust!

Last edited by Nextra; 10-14-2014 at 07:11.
Nextra is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-14-2014 , 08:06   Re: [HELP] How I can optimize this code?
Reply With Quote #2

@Klippy, just remember that that code is technically less efficient than simply implementing a switch. However, that is basically what I said for my alternative approach that is more flexible and is definitely worth it. Also, this is Scripting Help, you should try to have him learn something instead of doing it all for him.
__________________

Last edited by fysiks; 10-14-2014 at 08:07.
fysiks is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-14-2014 , 09:33   Re: [HELP] How I can optimize this code?
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
@Klippy, just remember that that code is technically less efficient than simply implementing a switch. However, that is basically what I said for my alternative approach that is more flexible and is definitely worth it.
You can (and should) also optimize code for readability and maintainability, so the almost non-existant performance improvement that a switch might provide is not really worth the tradeoff.
__________________
In Flames we trust!
Nextra is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-14-2014 , 13:02   Re: [HELP] How I can optimize this code?
Reply With Quote #4

Quote:
Originally Posted by Nextra View Post
You can (and should) also optimize code for readability and maintainability, so the almost non-existant performance improvement that a switch might provide is not really worth the tradeoff.
Hence why I said it "is definitely worth it".
__________________
fysiks is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-14-2014 , 13:40   Re: [HELP] How I can optimize this code?
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Hence why I said it "is definitely worth it".
I know that you understand and that you don't advise going the switch route. I just felt that I had to stress this a little more.
__________________
In Flames we trust!
Nextra 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 17:38.


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