Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
FlipBool with bitwise operators
function FlipBool($Bool) {
$Bool = ForceBool($Bool, 0);
return $Bool?0:1;
}
becomes
function FlipBool($Bool) {
$Bool = ForceBool($Bool, 0);
return $Bool ^ 1;
}
The performance gains will be huge! I say this patch be added to the core post-haste.
0
This discussion has been closed.
Comments
it's actually quite logical, in part because negative numbers are the same distance from 0 as their positive counter-parts. converting between positive and negative values is interesting: (a is 8 bits)
-a = 0 - a = 1111 1111 + 1 - a = (1111 1111 - a) + 1 = ~a + 1
and allows computers to easily subtract numbers: a - b can be seen as a + ~b + 1
and logical not (!) would probably be a better operator to use the the boolean not.