-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat: implement lazy file loading #306
Conversation
This reverts commit e9a4d25.
WalkthroughWalkthroughThe recent updates across various crates introduce enhancements in file handling, lazy loading, and pattern matching capabilities. New methods and modules streamline operations and extend functionality, particularly around file size checks and error logging. Enhancements in the pattern matching logic improve the efficiency and readability of the code, adapting it to handle dynamic file contexts and execution environments more effectively. Changes
Recent Review DetailsConfiguration used: .coderabbit.yaml Files selected for processing (4)
Files skipped from review as they are similar to previous changes (1)
Additional Context UsedLearnings (1)
Additional comments not posted (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 4
Out of diff range and nitpick comments (1)
crates/core/src/limits.rs (1)
9-9
: Consider addressing the TODO regarding the standardization of log levels to ensure consistent logging practices across the application.
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.
Actionable comments posted: 2
Out of diff range and nitpick comments (2)
crates/grit-pattern-matcher/src/pattern/state.rs (1)
77-79
: Consider adding documentation to clarify the purpose ofload_file
as a convenience wrapper forpush_revision
.crates/cli/src/commands/patterns_test.rs (1)
73-73
: Add a comment explaining the purpose of the debug print statement for better code clarity.
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (1)
crates/grit-pattern-matcher/src/pattern/contains.rs (1)
Line range hint
148-175
: Review the repeated execution logic for file patterns.- if self - .contains - .execute(resolved_pattern, &mut cur_state, context, logs)? - { - did_match = true; - } else { - cur_state = prev_state; - } - let prev_state = cur_state.clone(); - if self - .contains - .execute(&file.name(&cur_state.files), &mut cur_state, context, logs)? - { - did_match = true; - } else { - cur_state = prev_state; - } - let prev_state = cur_state.clone(); - if self.execute( - &file.binding(&cur_state.files), - &mut cur_state, - context, - logs, - )? { - did_match = true; - } else { - cur_state = prev_state; - } + // Simplify and optimize the repeated execution logic + let patterns_to_execute = [ + resolved_pattern, + &file.name(&cur_state.files), + &file.binding(&cur_state.files), + ]; + for pattern in patterns_to_execute.iter() { + let prev_state = cur_state.clone(); + if !self.contains.execute(pattern, &mut cur_state, context, logs)? { + cur_state = prev_state; + } else { + did_match = true; + break; + } + }
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.
Actionable comments posted: 8
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.
Actionable comments posted: 4
In large repos, it is very helpful to scope queries to specific files, but we don't really do this properly today (all files are read and parsed).
This refactors things so we only actually load the file once we start attempting to match on the
body
of thefile()
pattern.Summary by CodeRabbit
New Features
Enhancements
Bug Fixes
Documentation