You Just Gotta Love GCC
This afternoon I was working on my unsigned 128-bit integer class, UINT128, and realized that I needed to be able to swap byte orders in place, and so I wrote a little method on the class:
#include <byteswap.h> void UINT128::byteSwap() { mBlocks[0] = bswap_64(mBlocks[0]); mBlocks[1] = bswap_64(mBlocks[1]); }
and the thing I love about GCC today is that bswap_64() is a built-in function. Could it be any better? I did a little googling on byte swapping in GCC, and sure enough, there was exactly what I needed. Previously, I had been individually assigning bytes, and while it allowed for optimization, I'm guessing that this is way faster.
I need to remember to google first. It's almost always worth it.