4 ms·
For in-memory operations you would use uint32_t as normal, but for the memory structures which are going to be written to disk or sent over the network you woul
by cperciva 3y ago
For in-memory operations you would use uint32_t as normal, but for the memory structures which are going to be written to disk or sent over the network you would have ubeint32_t. When you assign the value from one to the other, the compiler would insert a byteswap if necessary.
Basically this would be a simpler replacement for explicit serialization of integers into bytes.
- Dylan16807 3y agoSo I have to write two versions of the data structure? I don't know if that sounds very simple to me, but it does sound like you could do that with a library and no language changes.
- cperciva 3y agoYou probably have two versions of the data structure anyway, since the data structure you want in memory is unlikely to be the data structure you want on disk or over the network. Your in-memory data structure probably has pointers, for example.