Using local statics
#1

Hello,

I have never ever used statics, so i was asking myself if i could do this, furthermore, what would you say is better?
So for example, i have this code:

PHP код:
    for(new 0sizeof(deadPlayers); ji++)
    {
        
deadPlayers[i] = "";
    } 
I am using this code to clear all strings in an array.
Looking at this code we can see, that every time it is called the size of "deadPlayers" will be retrieved.
So, if this code would be called very often (let us just say 200 times a second), should i do this instead?:

PHP код:
    static deadPlayersSize sizeof(deadPlayers);
    for(new 
0deadPlayersSizei++)
    {
        
deadPlayers[i] = "";
    } 
Just an example tho, no productive code
Reply
#2

Sizeof is an operator, not a function. The value only gets calculated once at compile time.
Reply
#3

Oh, good to know , thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)