Speaking of pred: you did not take it into account: This optimization is only valid if pred is "a == b".

good point, I have fixed it.