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

Need a lazy way to iterate files #73

Closed
yanex opened this issue Feb 22, 2018 · 6 comments
Closed

Need a lazy way to iterate files #73

yanex opened this issue Feb 22, 2018 · 6 comments
Assignees
Milestone

Comments

@yanex
Copy link

yanex commented Feb 22, 2018

UnrarKit currently returns info about all files in an archive as a NSArray. It is terribly inefficient in case if the archive contains lot of files.
There should be a way to iterate files lazily using an iterator.

@abbeycode
Copy link
Owner

abbeycode commented Feb 25, 2018

Interesting – I never considered that. The Unrar library definitely encourages the all-upfront approach. What sort of efficiency is problematic for you (time, memory, etc.)?

@yanex
Copy link
Author

yanex commented Feb 25, 2018

Both time and memory.
The biggest issue is that you will get OOM crashes if you have a lot of files inside the archive. Java had exactly the same problem in https://docs.oracle.com/javase/7/docs/api/java/io/File.html#listFiles() until it was completely fixed in the new Path API (which utilizes the visitor approach).
The other problem is that if I want to find a particular file inside an archive I have to firstly preload the whole list of names.

abbeycode added a commit that referenced this issue May 22, 2018
…e's file info without accumulating it (Issue #73)
@abbeycode
Copy link
Owner

@yanex I added this in the lazy-file-iteration branch, if you'd like to give it a shot. I'll merge into the v2.9 branch for release if it works for you, or after we refine it.

@abbeycode abbeycode self-assigned this May 22, 2018
@abbeycode abbeycode added this to the 2.9 milestone May 22, 2018
@abbeycode
Copy link
Owner

@yanex Have you had a chance to take a look?

@yanex
Copy link
Author

yanex commented Jul 19, 2018

Sorry for the late answer :(
Yes, the new way looks much better to me than just an NSArray. Good job! 👍

@abbeycode
Copy link
Owner

This has been merged for release in v2.9. Look for it in the next beta release (beta 11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants