Please add a comment which says that xor is used to preserve order independence.
It's not obvious from the code.