-
Notifications
You must be signed in to change notification settings - Fork 7
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
Optimize ArrayIterator #38
Comments
The BufferedIterator will also suffer similar performance issues when the maxBufferSize, as does the |
All major JavaScript engines implement behavior that is closer to O(1), see:
Trying to be faster ourselves will most likely have the opposite effect. |
Given the discussion in #44, we might want to see if alternatively implementations (notably a linked list) would speed this up. |
@RubenVerborgh interesting you should say that... I thought exactly the same, and came up with https://github.com/jacoscaz/AsyncIterator/blob/42311b68988a971fc072c896100d7082b4162470/asynciterator.ts#L744-L783 . I'm still testing it. Interested in a PR? |
That's quite perfect and exactly what I had in mind! (Nit: perhaps we should have that code in a separate file and include it.) |
It currently uses
.shift
which is a O(n) operation. So it costs O(n^2) to iterator over.The text was updated successfully, but these errors were encountered: