Code optimization questions
#2

You can't quite compare GlobalString with gString, because - well, one is available globally, and second one is only in local scope. You can accidentaly leak some data you don't want to share between functions. Local variables are destroyed once out of scope, so it won't give you some performance ultraboost.

pawn Код:
for(new i = 0; i < 5; ++i) {
    new j = 0;
    static k = 0;
    printf("Value of new: %d, value of static: %d", j, k);
    k++, j++;
}
You'll get:
Quote:

Value of new: 0, value of static: 0
Value of new: 0, value of static: 1
Value of new: 0, value of static: 2
Value of new: 0, value of static: 3
Value of new: 0, value of static: 4

Variable created with new is destroyed just after it's not in scope.
Reply


Messages In This Thread
Code optimization questions - by Gangs_Rocks - 01.08.2012, 12:26
Re: Code optimization questions - by Misiur - 01.08.2012, 12:38
Re: Code optimization questions - by Gangs_Rocks - 01.08.2012, 12:53
Re: Code optimization questions - by Misiur - 01.08.2012, 12:57

Forum Jump:


Users browsing this thread: 2 Guest(s)