Seems like this is more for
CodeReview, since the code is functioning alright. Regardless, a quick
microbenchmark
showed me that 3 and 2 were very close, and both were an order of magnitude faster than 5, and really 1,2,5 are all close to the same performance. I'm inferring that you have larger data in mind, though, so your own benchmark could easily bring up other nuances of the code. —
r2evans 10 secs ago