They are similar, but do we want if() in every loop iteration? Probably not.

Is there a point to extract one so simple loop to a separate function? Is it not too much overhead?