I agree that an array with constants should be faster, however, it would require more changes to the existing code than I'm up for at the moment. Moving the hash creation and key allocation out of the loop as suggested by hdb has helped.
I will try the array method when I get a chance.
Thanks!