Hoist function call from for loop exit conditions in spamf0 code.