-
-
Notifications
You must be signed in to change notification settings - Fork 16
Lazify dir reading #19
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
Conversation
95a8bf1 to
623d265
Compare
chshersh
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.
Great job!
I left a few minor comments about using the lazy pattern to slightly simplify some code.
But overall, I like how this refactoring was straightforward 🏆
lib/fs/fs.ml
Outdated
| | Dir (name, children) -> | ||
| let children = Lazy.force children in |
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.
Let's use the lazy pattern in the pattern matching itself instead of Lazy.force. The behavior will be the same but the code will be slightly terser:
| Dir (name, lazy children) ->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.
awesome I didn't realize you could do that!
lib/fs/fs.ml
Outdated
| current = File_cursor (Lazy.force contents); | ||
| } | ||
| | Dir (_, next) -> | ||
| let next = Lazy.force next in |
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.
Same comment about the lazy pattern
| | Dir_selected { children; prev_total; pos } -> ( | ||
| let children = Lazy.force children in | ||
| match children with | ||
| (* No children of a directory without children *) | ||
| | [||] -> Empty_directory | ||
| (* Non-empty array of children *) | ||
| | _ -> Directory_contents (children_to_doc ~prev_total ~pos children)) |
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 think here it's fine to keep Lazy.force because there's no elegant way to pattern-match on a lazy pattern inside record.
|
@heathhenley CI was failing due to some bug in the I updated the CI, so if you update branches, the CI should start working again. |
623d265 to
611cdaf
Compare
Co-authored-by: Dmitrii Kovanikov <[email protected]>
|
I think I addressed them all - let me know what you think! |
chshersh
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.
Awesome stuff! Let's go!
An attempt to address #5
Switched type of tree so that that dir is a Lazy.t and added Lazy.force where needed.