2 ms·
I think the author expected that creating a u16 view over a buffer up front and then writing to it would perform better than writing one-off to a single pair as
by iudqnolq 3y ago
I think the author expected that creating a u16 view over a buffer up front and then writing to it would perform better than writing one-off to a single pair as a u16.
If they're gonna optimize further I think they may as well go all the way through. This'll be pretty readable in the context of a binary serializer codebase
b[2] = value >>> 8;
b[3] = value & 0xff;