Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Whether it is tricky depends on what platforms you care about.


Or, you can just follow the advice of the article, and not need to worry about it because the compiler takes care of it for you.


> because the compiler takes care of it for you.

It will always be correct, but you can't just assume that the compiler will optimize the shifts into a byteswap instructions. If you look at the article you will see that it tires to no-true-scotsman that concern away by talking about a "good modern compiler".


And what exactly is the problem there? Are you going to be writing code that a) is built with a weird enough compiler that it fails this optimisation but also b) does byte swapping in a performance critical section?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: