Break the loop once the result can no longer change.

This reduces bitwise ops abuse and makes the loop a bit faster.