Raised This Month: $ Target: $400
 0% 

Is this execution correct?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2022 , 07:05   Re: Is this execution correct?
Reply With Quote #4

1. fysiks is correct. sizeof is an operator and its result is known at compile time. The compilr replaces it with the actual value in the generated binary.
There is no runtime overhead.

Things are different with something like ArraySize, which is a function. It should be cached before the loop to avoid the runtime overhead of calling the function(pushing, popping the stack, jumping in a different code location) with each loop iteration.

2. I again must agree with fysiks. He explained it well so I will not reiterate. I just want to say that static is not meant to be used as an optimization technique. It can be used as such in very specific scenarios, but this is a side effect of how static works and not its main purpose.
__________________

Last edited by HamletEagle; 07-22-2022 at 07:11.
HamletEagle is offline
 



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 15:38.


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