Quote:
Originally Posted by Branks
accessing multi dimensional arrays, ive heard this is slow enough to be avoided when its possible, however some situations such as Mob::SpellEffect which various cases within, will need to access the array which holds AA spell IDs and recourses of AA spell Ids, would it be better to store these commonly checked spell IDs in global variables? instead of accessing the array each pass?
|
This has no overhead at all in C or C++. It may in Java or other languages, but in C the entire multidimensional array is stored linearly in one block of memory with each row immediately after the previous row. He said you could store it as a single dimensional array and refer to it with [column +(row*num_columns)] and you can if you want, but that is exactly what the program does when you put [row][column]. You can even declare it as two dimension and type cast it to one dimension and refer to it interchangably. So the only over head is a pointer look up and an addition and multiplication, if you worry over that then you should see a shrink.
Quote:
Originally Posted by Branks
also, the question about static variables declared within a class method, are these created for every instance of a class or does every instance of a class use the same method and therefor the static variables only exsist once?
|
I don't think you can declare a static variable inside a method, and even if you can it will do absolutely nothing because variables declared in a method cease to exist once the method stops running. Of course if you have two instances of the method running at the same time it may make them share the variables, but I have no idea.