3 ms·
You can combine the two XORs: new_mask = old_mask XOR old_char XOR new_char count += signum(new_mask - old_mask) Where signum(x) = (x > 0) - (x < 0)
by meindnoch 4y ago
You can combine the two XORs:
new_mask = old_mask XOR old_char XOR new_char
count += signum(new_mask - old_mask)
Where signum(x) = (x > 0) - (x < 0)