Hi guys,
I was playing a bit with optimizations, and since I have custom binary format I wanted to optimized it.
I have managed to replace a lot of buffer.ReadUInt16() with bit shifting, it’s slightly faster like this:
byte[] vectorBuffer = new byte[2 * 3];
buf.Read(vectorBuffer, 0, 6);
var x = (ushort)(vectorBuffer[0] | vectorBuffer[1] << 8);
I want to further optimized but couldn’t manage to get the same thing for 4 byte values like floats, I know it has something to do with endianes but couldn’t swap bits the way it would produce correct values. I have something like this: