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

Ridiculous optimizations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dataviruset
AlliedModders Donor
Join Date: Feb 2009
Location: Hong Kong
Old 04-07-2010 , 19:08   Ridiculous optimizations
Reply With Quote #1

Hello, I am a bit tired and I don't care whatever you say, but, yeah.
No matter how important it is, I want to optimize this stupid bit of code. I just wonder, haha.

Which alternative would be the best?

PHP Code:
// alternative 1
SetEntityGravity(LRprogressplayer1GetConVarFloat(sm_hosties_lr_db_gravity));
SetEntityGravity(LRprogressplayer2GetConVarFloat(sm_hosties_lr_db_gravity));

// alternative 2
new Float:gravity GetConVarFloat(sm_hosties_lr_db_gravity);
SetEntityGravity(LRprogressplayer1gravity);
SetEntityGravity(LRprogressplayer2gravity); 

Last edited by dataviruset; 04-07-2010 at 20:30.
dataviruset is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 04-07-2010 , 19:36   Re: Ridiculous optimizations
Reply With Quote #2

lol.. Id doubt that makes any difference...

Obviously the less getconvarint's,floats,etc you do, the better....so the second example would be better....

Personally, if it were me, I might not even do either of those ways.

If you have to get that convar many times, Id make a global and set the value of the cvar to the global OnConfigsExecuted. Then you never have to getconvarfloat on a bunch of stuff(assuming you had a bunch of stuff) when running the code..... I see many people making those mistakes a lot and have a billion getconvar**** for stuff thats used repeatedly.

If you only use it once in that instance, the second example is fine. Its common sense coding really, if you getconvarfloat once, why get it again, or a third time, or forth time, etc...

Last edited by retsam; 04-08-2010 at 00:17.
retsam is offline
BAILOPAN
Join Date: Jan 2004
Old 04-08-2010 , 02:13   Re: Ridiculous optimizations
Reply With Quote #3

Write code that is simpler and easier to maintain. I think the bottom one fits the bill.
__________________
egg
BAILOPAN 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 10:44.


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