Performance Question at the Assembly Level

My programs typically often reference references within references, meaning I have an array within an array within an array. Is there any performance decrease from this or does it not matter? For example I will say:

xCords[x].xVerts[y].vertices[z] (just as a notational example)

Since I’m typically looping through large groups of these, is there a performance benefit to making a pointer point to xCords[x].xVerts[y] and then to say pointer.vertices[z]? Or is the only advantage shorter lines of code?

Thanks a bunch


Yep,using a special pointer within a loop will probably let the compiler keep it in a register and this will speed things up if it gets dereferenced a lot.But you better test for yourself by timing the loop with both versions.

That depends on the situation, but normally a good compiler should optimize such things automatically, so it shouldn’t really matter.

Keeping a pointer to a structure element that is accessed more than once in a register is one of the most basic optimizations, so most compilers should support it. Just be sure that the optimizations are turned on.