3 ms·
You'd better hope that a!=b
by ur-whale 8y ago
You'd better hope that a!=b
- scj 8y agoWhy would a==b be a problem with the XOR swap trick? function xorSwapTest(min, max) { for (var i = min; i < max; i++) { var a = i, b = i; b ^= a; a ^= b; b ^= a; if (a != i || b != i) throw Error("Problem with " + i); } return true; }
- saagarjha 8y agoThe issue is that if a == b, &s[a] == &s[b]; i.e. you're writing to the same address.
- and-then 8y agoEdge-case FUD.