6 ms·
I know that's the standard but for all private projects I always write little endian so I can sleep soundly at night knowing I've saved precious picoseconds not
by kuroguro 2y ago
I know that's the standard but for all private projects I always write little endian so I can sleep soundly at night knowing I've saved precious picoseconds not flipping to cpu order.
- crest 2y agoMost CPUs suitable to implement such a protocol can do endian swapping for free e.g. a load+bswap instruction, a microarchitecture that fuses load+bswap. Don't worry about byte swapping fixed sized int across the network. Just keep in mind that for some applications it maters e.g. most bignum operations favour little endian, but databases profit from big endian (memcmp sorts in numerical order).
- kuroguro 2y agoHuh, good to know. I guess the only other downside is actually making the compiler do the bswap depending on the language. Eg C has some weird compiler specific builtin keywords vs zig has a nice packed struct that does it for you.