no it doesn't, the
static unsigned int t=0, r=0, s=0;
variables are only initialized with 0 when the function is executed
the first time, from the on the variables keep their values. (static
definition)
I've attached a small prog that demonstrates the function. Just
compile and run it and you will see that it does the same like the
old code. For better readabilty the =0's could also be removed, but
then you would have to make sure, that the resetgradients is false
before you execute the function first.
The benefit of this patch is not allways have to execute these loops,
(the test if (!gradientUpdated[t][r][s]) was executed
MAX_RESSOURCES*numberOfTeam times on average, and allways the
counting variables of the loop had to be incremented and tested) and
not have to use this array anymore (saving some memory)
ok, sorry, I didn't read it carefully enough.
Well, "static" variable must not be used. They are opposed to a good
object-oriented design. You still can make the same if you put them
(t, r, s)
in the object. In such a case, they would need longer explicit names.
Like "teamScheludIterator", "ressourceSchedluIterator",
"swimSchedulIterator",
or something similar.
About the speed: This will not provide any noticeable speed improvement.
The clarity of the code is much more imporant! (much much more). If you
think it's more clear with 3 integers, then we'll use it!
Can you make such a patch ?
Thank you!
Nuage