Honestly that seems a lot more complicated than this is, this code is also run only once so these small optimisations doesn't do that much, the original code is reasonably fast anyways.