Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make only one copy of the data #58

Closed
make-github-pseudonymous-again opened this issue Sep 14, 2021 · 3 comments
Closed

Make only one copy of the data #58

make-github-pseudonymous-again opened this issue Sep 14, 2021 · 3 comments

Comments

@make-github-pseudonymous-again
Copy link
Member

Since we do not deep copy values and since we do not expose copies this makes no difference. Would suffice to keep track of indices for each copy in a single buffer, when all indices > 0 we can shift the deque left and decrease all counters. To make this check efficient we can use a +1/-1 heap.

@make-github-pseudonymous-again
Copy link
Member Author

make-github-pseudonymous-again commented Sep 14, 2021

Note that this would in almost all cases use less space, and be considerably more efficient in the case where we have a a few copies where one of them gets read much more than the others.

PS: Having one copy read much more than the others is what happens when using product([infiniteIterable], 10).

@make-github-pseudonymous-again
Copy link
Member Author

Use a singly linked list instead.

@make-github-pseudonymous-again
Copy link
Member Author

make-github-pseudonymous-again commented Sep 17, 2021

If implementing this, test the following:

  • An item is only pulled from the source iterable if it is accessed at least once
  • A pulled item can be garbage collected as soon as it has been pulled in all copies and the consumer has lost all references to it (cannot really check this?)

make-github-pseudonymous-again added a commit that referenced this issue Sep 21, 2021
Fixes #58.

BREAKING CHANGE: We now return an IterableIterator instead of a list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant