Is a global string var better then smaller ones?
#6

Quote:
Originally Posted by Norn
Посмотреть сообщение
Obviously reusing one large one would save memory but it would also cause problems if misused.
Correct. I use 5 global strings spread throughout a 23K line gamemode. No problems here.

Quote:
Originally Posted by The Toni
Посмотреть сообщение
Would misusing it count as not clearing the variable?
No. Misusing it would mean setting in, passing to a function that overwrites it, then back to the main function where it gets used again.

Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
I'd assume using a global string wouldn't be terrible. PAWN is single-threaded, so two things can't happen at the exact same time. Therefore, one variable can't be in use in two places simultaneously.

Correct me if I'm wrong.
Most people here preach using global strings as a tool of the devil. They usually do that because they're parroting what someone else said, because they have no clue what they're doing, or because they don't even run a server to begin with.

PAWN is single-threaded though plugins with multi-threaded features (i.e. G-Stylez MySQL) do exist. There you need to be careful.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)