Why not use a global string[128]? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why not use a global string[128]? (
/showthread.php?tid=424871)
Why not use a global string[128]? -
trollkemada - 24.03.2013
I've been watching a lot of code and very frecuently i see that people declare a new string[128]; in almost every function that needto send any msg.
What's bad about having a global string[128] and use it in all functions? (so you dont have to allocate more and more stack memory in each function call)
Re: Why not use a global string[128]? -
kamzaf - 24.03.2013
The bad thing in declaring a global string of lets say 128 cells is that at times you may need to change the amount of cells needed at times because the length of the line could be alot and your cells could be less and sometimes your using only 20-30 cells but declaring 128. which is a waste of about 80-90 cells.
Re: Why not use a global string[128]? -
ReneG - 24.03.2013
Quote:
Originally Posted by trollkemada
What's bad about having a global string[128] and use it in all functions?
|
Nothing. Pawn is single-threaded so it's safe.
Modern PC's can handle more than you think. It makes no sense worrying about premature optimization.
Re: Why not use a global string[128]? -
P3DRO - 24.03.2013
but its a optimization never the less. For more insignificant it is its still an optimization and i declare some global strings, but only those i use almost everytime.