Basically I am amidst a friendly code optimisation battle (to get the fastest program), I am trying to find a way that is faster to access a dictionary of hard coded data than a multidimensional array.
e.g to get the value for x:
int x = array[v1][v2][v3] ;
I have read that nested switch statements in a custom array may possibly be faster. Or is there a way I can possibly access memory more directly similar to pointers in C. Any ideas appreciated!
My ‘competitor’ is using a truth table and idea is to find something faster!
Many Thanks
Sam
If the array is regular in shape (i.e.
MxNxKfor some fixedM,NandK), you could try flattening it to achieve better locality of reference:Also, if the entire array doesn’t fit in the CPU cache, you might want to examine the patterns in which the array is accessed, to perhaps re-order the indices or change your code to make better use of the caches.