Why not use a global string[128]?
#1

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)
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)