News for hackers. Stuff that matters.
Re:Low Level Bit Hacks You Absolutely Must Know by ori_b on Tuesday June 30, 2009 @09:10PM (#681922)
Assume you had a sorting algorithm that swaps values, and in some cases would swap two of the same values. It's easier (and often faster, thanks to the high cost of branch misprediction) to simply assume the swap of something with itself is a no-op than to explicitly check the address of the value to make sure it isn't the same. Or you could have just forgotten to make the check, and allowed the user to pass in their own swap functions (say, to deep-copy structs in C).

There are no comments on this comment yet.