Inlining iterator equality, adding a short-circuit end flag, and making end be called only once per loop