|
|
|
|
|
by Veserv
69 days ago
|
|
You should actually not use format-swapping operations. You should actually use format-swapping loads/stores (i.e deserialization/serialization). This is because your computer can not compute on values of non-native endianness. As such, the value is logically converted back and forth on every operation. Of course, a competent optimizer can elide these conversions, but such actions fundamentally lack machine sympathy. The better model is viewing the endianness as a serialization format and converting at the boundaries of your compute engine. This ensures you only need to care about endianness when serializing and deserializing wire formats and that you have no accidental mixing of formats in your internals; everything has been parsed to native before any computation occurs. Essentially, non-native endianness should only exist in memory and preferably only memory filled in by the outside world before being parsed. |
|