-
Notifications
You must be signed in to change notification settings - Fork 4
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
Remove redundant validation when enumerating files & folders in SystemFile/SystemFolder. #56
Remove redundant validation when enumerating files & folders in SystemFile/SystemFolder. #56
Conversation
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.
This is a great change. The constructor validation/guard is largely meant for consumers who might provide an invalid or nonexistent path. A file or folder resource should exist before it's accessed through our abstraction.
That means instances that are created internally can pre-validate this and skip the consumer-facing validation/guard.
It's a free performance gain that might be especially noticeable for extremely large storage graphs.
My only suggestion is that we rename this from isInternal
to something more descriptive of what it does. Maybe we just call it noValidation
and keep the constructor internal?
I've merged the PR with the requested changes. |
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.
Great work here, we'll get this out in the next version bump.
Just added even more optimizations that should get the enumeration time in tests to less than 1ms in most cases. Using |
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.
New changes look good!
Exists()
check when enumerating files & folders in SystemFile/SystemFolder.
Currently, when enumerating or copying files, we are checking whether the file exists or not in the constructor. This can cause unnecessary huge disk I/O overhead especially with large folders.
A new internal constructor is created specifically to prevent this scenario (only creates an instance with the necessary item info, nothing else), since in these cases we already know that the file/folder indeed exists.
cc. @HEIC-to-JPEG-Dev feel free to review.