strlen is called many times in loops as well, no need to keep doing that if the length hasn't changed.