Wrap redundant reduce and reduceRight code in helper

The loops could be further abstracted, but I didn't like how it looked after going that far

Fixes #1734 
Well it just seems odd that you have all of the information you need to de-duplicate the code and then don't make use of it. But things done in the name of performance are always odd.