|
|
I've set a macro to move across an array. Since it
has to derive where to begin calculating, it must always
begin with the first element, but then may jump across
certain sections, and end before it reaches the end of
the array.
Problem is: it would always calculate the first element
this way, which might not be wanted.
In order to solve this, I've decided the following:
since the x and y part of the vector saved in the array
defines where to jump next in the 2D-Array, I just add
the dimension-size of the x-dimension to the movement-
value of x. Thus, I have means of checking if the array
would (theoretically) exceed its size, and using mod()
I can easily revert the process.
But what would be better implementation-wise:
Checking with #if, if the value of x is too large, and
apply mod() if needed (can only happen on the initial
element, so I could combine the #if with checking if
the macro is to access the first element), or by applying
mod anyway? At this point, the macro doesn't decide
anything, it just needs to derive which point it has to
jump to next.
I'd think applying mod() every time would be better than
always calculating an #if statement, and applying the
mod() if needed, but perhaps someone has better insight?
If anyone doesn't understand what I'm doing, perhaps this
suffices:
Is it better to apply mod() in every step, or use an #if in every
step in order to know if mod() should be applied? What is less
costly parsing-wise?
--
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde
Post a reply to this message
|
|