Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Finder] Use a lazyIterator to close files descriptors when no longer used#40040
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
b984368 toc1b3e9bComparecarsonbot commentedJan 31, 2021
Hey! This is.. this is amazing. Thank you! I think@hurricane-voronin has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Uh oh!
There was an error while loading.Please reload this page.
1788517 tocb94f87CompareUh oh!
There was an error while loading.Please reload this page.
ro0NL commentedFeb 5, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
im wondering if eg. roughly :) |
jderusse commentedFeb 5, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That's not possible, edit: I missed the trick with |
jderusse commentedFeb 5, 2021
Refactored to use IteratorAggregate . |
ro0NL left a comment
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.
👍🏻 for LazyIterator as feature also, given Finder::append() supports aggregates, eg.Finder::append(new LazyIterator($callable)) works.
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedFeb 12, 2021
Thank you@jderusse. |
| /** | ||
| * @author Jérémy Derussé <jeremy@derusse.com> | ||
| */ | ||
| class LazyIterator implements \IteratorAggregate |
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.
should we mark it as@internal ?
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 agree, see#40163
This PR was merged into the 4.4 branch.Discussion----------[Finder] mark the LazyIterator class as internal| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets |#40040 (comment)| License | MIT| Doc PR |Commits-------4a2c996 mark the LazyIterator class as internal
This PR was merged into the 4.4 branch.Discussion----------[Finder] mark the LazyIterator class as internal| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets |symfony/symfony#40040 (comment)| License | MIT| Doc PR |Commits-------8e69df8 mark the LazyIterator class as internal
The
RecursiveDirectoryIteratorclass open the file on__construct.Because we Inject an instance of
RecursiveDirectoryIteratorinside the \AppendIterator` class, php opens a lot of file even before iterating on it.This PR adds a new
LazyIteratorclass that instantiate the decorated class only when something starts iterating on it.When the iteration is over, it unset the variable to close let the decorated class clean things (ie. close the files)