Reasons For Use in Practice
In most practical scenarios, the trivial swap algorithm using a temporary register is more efficient. Limited situations in which XOR swapping may be practical include:
- On a processor where the instruction set encoding permits the XOR swap to be encoded in a smaller number of bytes;
- In a region with high register pressure, it may allow the register allocator to avoid spilling a register.
- In microcontrollers where available RAM is very limited.
Because these situations are rare, most optimizing compilers do not generate XOR swap code.
Read more about this topic: XOR Swap Algorithm
Famous quotes containing the words reasons for, reasons and/or practice:
“Could truth perhaps be a woman who has reasons for not permitting her reasons to be seen? Could her name perhaps beto speak GreekBaubo?... Oh, those Greeks! They understood how to live: to do that it is necessary to stop bravely at the surface, the fold, the skin, to adore the appearance, to believe in forms, in tones, in words, in the whole Olympus of appearance! Those Greeks were superficialout of profundity!”
—Friedrich Nietzsche (18441900)
“With no matter what human being, taken individually, I always find reasons for concluding that sorrow and misfortune do not suit him; either because he seems too mediocre for anything so great, or, on the contrary, too precious to be destroyed.”
—Simone Weil (19091943)
“In my practice Ive seen how people have allowed their humanity to drain away. Only it happens slowly instead of all at once. I didnt seem to mind.... All of us, a little bit. We harden our hearts. Grow callous. Only when we have to fight to stay human do we realize how precious it is to us, how dear.”
—Daniel Mainwaring (19021977)