Faster version of all_same, remove redundant is_constant