
7 Aug
2008
7 Aug
'08
6:09 p.m.
But with a index you need two variables, the base pointer + index. And unless your compiler + instruction set allows you to addess a memory location using a base pointer + index then you are going to loose much in performance. IMHO a pointer is always faster, it let you write the algorithm in a different way avoiding probably the example you gave above.
Did you do the actual performances check ? On decent compiler for non-exotic architectures the difference is really thin for L1 cache compliant number of elements. I have nothing against pointer anyway but good data structure like Numerical Recipes multi-dimensionnal allocation makes things easier with a very small overhead.