tokahuke / yaque

Yaque is yet another disk-backed persistent queue for Rust.
Other
79 stars 11 forks source link

`xor` is not xor #17

Open whonore opened 2 years ago

whonore commented 2 years ago

xor in header.rs does not actually compute the exclusive or of a and b. Instead it checks that a and b are either both true or both false, which is equivalent to a == b. I don't understand what decode does well enough to know if this is the intended behavior or not, but either the name or the implementation is currently wrong. If you do actually need xor there's the ^ operator and the BitXor trait.

NinoScript commented 2 years ago

You're right, that code is the opposite of a xor, it's an xnor: !(a ^ b)