33% speed increase by removing redundant is_outside checks that were guaranteed to be safe by the loop conditions.