What would be the fastest way to pack two bytes into one? I have a large array of bytes. Each byte represents a number not larger than 15 (4-bit number). Because of that I could pack two bytes into one, placing the first byte into the higher nibble and the later in to the lower nibble.
My current approach is to create a second array half the size of the original and then to iterate over the original array shifting it and | to get the nibbles. This works however it takes a while depending on the size of the array. The arrays are from a few thousand entries to a few million. It's not catastrophic but any optimization would be helpful