Avoid allocating an iterator when the list is empty.

@danrice-square or anyone.