3 ms·
Portability woes: Endianness and Alignment, Part 2
- justin66 12y agoPeople should read Rob Pike's "The byte order fallacy," which was already discussed here: https://news.ycombinator.com/item?id=3796378 https://news.ycombinator.com/item?id=3796378 http://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html http://commandcenter.blogspot.com/2012/04/byte-order-fallacy...
- vardump 12y agoI have a lot of respect for Rob Pike. Doing what he says guarantees correct operation in typical cases, when the memory is cacheable. If CPU arch doesn't support unaligned loads, the compiler must additionally be able to deduce pointer alignment or it's forced to generate separate loads. However, if performance is important, doing what Pike says doesn't always make sense. The case discussed in the article in question is one those.