Code:
#define PLUGIN "Simple Slots Reservation"
#define VERSION "0.0.6"
After compilation, same string is replaced everywhere.
Compiler allocates 3 times the same string:
Code:
public plugin_init()
{
register_plugin("Simple Slots Reservation", "0.0.6", "Jhob94")
register_cvar("Simple Slots Reservation", "0.0.6", FCVAR_SPONLY|FCVAR_SERVER)
set_cvar_string("Simple Slots Reservation", "0.0.6")
}
VS
Code:
new const PLUGIN[] = "Simple Slots Reservation";
new const VERSION[] = "0.0.6";
After compilation, string is allocated one time and this will use references
anywhere string is repeated.
Code:
public plugin_init()
{
register_plugin(referenceString_1, referenceString_2, "Jhob94")
register_cvar(referenceString_1, referenceString_2, FCVAR_SPONLY|FCVAR_SERVER)
set_cvar_string(referenceString_1, referenceString_2)
}
Basically, if you have a string which is referenced more than one time, this is good idea to use
new const
EDIT: Shit, ninja'd! \o/
Though I'm not sure to agree to
Quote:
the memory will be allocated (and free'd) each time the string is used, which is a waste of computing power (not that it really matters, though).
|
Maybe I've misunderstood, but string is allocated one time and is referenced anyway by an address ; the point is just for a same string repeated x times, plugin will allocate x times with a x addresses.
__________________