Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline the basic Iterator.push-exactly
Instead of counting up to the given number, copy the given number and count down with it, which simplifies the end check. Makes it about 8% faster.
- Loading branch information
9d784dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the returned value should be
$n - $todo
9d784dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. The return of
push-exactly
should be:If it reached the end of the iterator, then
IterationEnd
is returned. Otherwise it returns the number of items pushed: if it didn't reach the end, that would be the number of things requested, aka$n
Or am I missing something?
9d784dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right right, I didn't pay attention to the
if
statement that surrounds the return value. Nevermind.To be fair, it would still be correct as
$todo
would always be0
at that statement.