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

Hook function arguments with const will increase performance?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 10-15-2016 , 12:17   Hook function arguments with const will increase performance?
Reply With Quote #1

For example we hooked takedamage event with Ham:
PHP Code:
RegisterHamHam_TakeDamage "player" "Ham_TakeDamage_Pre" )

I) public Ham_TakeDamage_PreiVictimID , ... )
II) public Ham_TakeDamage_Pre( const iVictimID , const ... ) 
will this increase performance?
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-15-2016 , 14:46   Re: Hook function arguments with const will increase performance?
Reply With Quote #2

If it does it will be negligible. You shouldn't worry about trivial optimizations.
__________________

Last edited by fysiks; 10-15-2016 at 14:47.
fysiks is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 10-15-2016 , 15:19   Re: Hook function arguments with const will increase performance?
Reply With Quote #3

From 0.0000001 to 0.000002, maybe.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 10-15-2016 , 15:25   Re: Hook function arguments with const will increase performance?
Reply With Quote #4

This is only for protect variable from change.
__________________

Last edited by PRoSToTeM@; 10-16-2016 at 18:33.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 10-15-2016 , 17:03   Re: Hook function arguments with const will increase performance?
Reply With Quote #5

Quote:
Originally Posted by meTaLiCroSS View Post
From 0.0000001 to 0.000002, maybe.
Thats 20 times more. Pretty good imo.
__________________

Last edited by Black Rose; 10-15-2016 at 17:04.
Black Rose is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 10-16-2016 , 18:19   Re: Hook function arguments with const will increase performance?
Reply With Quote #6

Quote:
Originally Posted by Black Rose View Post
Thats 20 times more. Pretty good imo.
Forgot a zero
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-16-2016 , 21:57   Re: Hook function arguments with const will increase performance?
Reply With Quote #7

The value of a single variable cannot be modified unless you pass it by reference. Only arrays really need 'const' to protect it from being modified since they are passed by ref by default. I don't see why there would be a performance benefit.
__________________

Last edited by Bugsy; 10-16-2016 at 22:02.
Bugsy 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 21:16.


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