View Single Post
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 07-22-2022 , 15:14   Re: Is this execution correct?
Reply With Quote #5

I am sorry for the first advice. Though I knew that sizeof in C is calculated at compile time, I had no luck to find any confirmation regarding PAWN.

"If it's relatively small and the function is not called very often"
Why did you decide that the function is not called very often? In fact I do not see any function at all, just the code. There is no function signature or event hook declared.

"This is not good advice. If something is only used in that function and has no usefulness to other areas of code, it should not be global (making a local variable/constant global just pollutes the global namespace)."
If a variable is used only in one function, I agree it should be declared in that function.
If a constant is never changes, like PI, it can be declared in a function.
But when a constant is subject to change I would prefer to have it global, just for convenience for future edits. I was kind of thinking that perks_id is subject to change, and so I would move it out of the function to simplify future edits and to reduce the number of memory allocations.
damage220 is offline