10x faster implementation of swapEndianness that does not mutatate the original buf array