tom_usenet said:
However, the performance benefit from the code for each case being
inlined might outweight the benefit you get in just doing an array
dereference. Calling through a function pointer disables inlining
(usually).
Just to emphasis the point.
Once upon a time (back in 1982), I profiled some C code
compiled on an 16 bit computer and found that 40% of the
time was spent converting 16 bit ints to 32 bit ints doing
pointer arithmetic. Using that particular compiler
microlevel optimizations were a complete waste of time.
Microlevel optimization ought to be the last thing you do,
after you have profiled your code and really discovered
where the bottlenecks are. As others have said these
optimizations may gain you a few percentage points in
performance. Smarter algorithms and data structures, on the
other hand can gain you orders of magnitude better performance.