Help optimizing a function

Just initializing the array

I don't think so - it accesses an element off the end of the array and does nothing with it. That might be at least part of your problem.

Pete