Use SmallVectorImpl instead of SmallVector for iterators and references to avoid specifying the vector size unnecessarily.