-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implemented yielding Dir.each_child #4811
Conversation
Ooops, build on 32-bit linux box failed with sigfault:
|
Are we hitting the memory limit of Travis 32-bit VM? Maybe we should build |
@ysbaddaden I don't think that specific segfault is because of memory, but I may be proven wrong. Typically memory issues appear when |
Maybe initialize a few rebuilds to determine if the error is persistent? |
@straight-shoota It's not, this error has been around for months. |
@ysbaddaden @RX14 Coming back to the topic of this PR, shall we get this merged or shall I open another one, changing name conventions as noted in #4808 (comment)? |
Well we need |
@RX14 done. |
@Sija I think you missed that. Especially Note: do we want to have |
Thanks, you're right, I've changed it.
I'd say yes. WDYT @ysbaddaden @RX14 ? |
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.
Good job!
Usually we'll want to return an array for easyness (e.g. to pass it along to a template), sometimes we'll want to yield a folder and don't need an array (avoids HEAP allocation), and we may need the full directory listing, including |
@ysbaddaden said & done, ready for review :) |
src/dir.cr
Outdated
excluded = {".", ".."} | ||
entry = nil | ||
loop do | ||
break unless excluded.includes?(entry = @dir.read) |
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.
Why not use early return here?
excluded = {".", ".."}
loop do
entry = @dir.read
return entry unless excluded.includes? entry
end
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.
fixed.
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.
Can I suggest another one?
excluded = {".", ".."}
while entry = @dir.read
return entry unless excluded.includes? entry
end
stop
Nevermind you don't have to include that one, just wanted to write it somewhere..
Edit: oh in fact you implemented it that way too, perfect then 😆
5a9f80b
to
606f283
Compare
Anything more to do here, or is it GTG? |
@Sija, @ysbaddaden hasn't reviewed the latest changes. |
@ysbaddaden ping |
Thank you! |
still awesome experience, so yw, thx! |
Complements #4808