-
Notifications
You must be signed in to change notification settings - Fork 0
feat: reversed_sorter_apply_order
#25
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughA new boolean flag, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Launcher
participant Batcher
User->>Launcher: reversed_sorter_apply_order(flag)
Launcher->>Batcher: Set reversed_sorter_apply_order = flag
User->>Launcher: (trigger sorting)
Launcher->>Batcher: create_sorter()
Batcher->>Batcher: Apply sorters (normal or reversed order based on flag)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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.
Summary of Changes
Hello @satler-git, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've implemented a new feature that provides more flexibility in how sorters are applied. This change introduces a mechanism to reverse the order in which multiple sorters are processed, allowing for different sorting behaviors without altering the individual sorter definitions. This enhances the configurability of the batching and sorting logic.
Highlights
- New Sorting Order Control: I've introduced a new
reversed_sorter_apply_orderflag within theBatcherstruct. This flag controls whether the defined sorters are applied in their original sequence or in reverse order, offering more control over the sorting process. - Public API for Launcher: To expose this new functionality, I've added a public method
reversed_sorter_apply_orderto theLauncherstruct. This allows external users to easily configure the sorter application order. - Dynamic Sorter Application: The internal
create_sorterfunction inBatcherhas been updated to dynamically iterate through the sorters. It now uses a newcompare!macro and conditional loops to apply sorters either forwards or in reverse, depending on thereversed_sorter_apply_orderflag.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces a feature to reverse the application order of sorters. The implementation is sound, but I have a couple of suggestions to improve maintainability. I've recommended adding documentation for the new public API and refactoring the sorting logic to be more idiomatic and readable by removing a macro and duplicated code.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
CodSpeed Performance ReportMerging #25 will degrade performances by 17.99%Comparing Summary
Benchmarks breakdown
|
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: 1
🧹 Nitpick comments (4)
src/launcher/batcher.rs (3)
31-31: Document the new flag and clarify its semanticsPlease add a short doc comment clarifying that this flag reverses the order of applying sorters (i.e., last → first), which changes tie-breaker priority, and that the default is false. This helps distinguish it from
reverse_sorter, which flips the final ordering direction without changing priority.Example:
pub struct Batcher<'a, Cushion, UIContext> { @@ - pub(super) reversed_sorter_apply_order: bool, + /// If true, apply sorters in reverse declaration order (last → first) when comparing. + /// This changes the tie-breaker priority among sorters. Default is false. + pub(super) reversed_sorter_apply_order: bool, @@ - reversed_sorter_apply_order: false, + // Apply sorters in forward order by default (first → last). + reversed_sorter_apply_order: false,Also applies to: 50-50
142-142: Local import is fine; optional: avoid shadow imports for clarityUsing
use std::cmp::Ordering;inside the closure is valid, but in practice pulling the type at module scope or qualifying (e.g.,std::cmp::Ordering::Equal) can improve readability and reduce repetition across closures.
147-163: Comparator macro is correct; consider inlining for readabilityThe macro correctly short-circuits and uses
continuewithin the loops. If you prefer to avoid macros here, you can inline the body once per loop using a tiny helper closure to compute the finalOrdering, keeping the logic local and explicit.For example:
- macro_rules! compare { - ($i:ident) => { - match self.sorters[$i].compare(lhs, rhs, &self.state.input) { - Ordering::Equal => { - continue; - } - ord => { - return if self.reverse_sorter { - ord.reverse() - } else { - ord - }; - } - } - }; - } + let mut finalize = |ord: Ordering| { + if self.reverse_sorter { ord.reverse() } else { ord } + };And use the body directly in each loop:
let ord = self.sorters[i].compare(lhs, rhs, &self.state.input); if ord != Ordering::Equal { return finalize(ord); }This keeps the flow explicit with minimal duplication.
src/launcher.rs (1)
185-188: Add docs for the new API and align naming withreverse_sorterThe method is correctly wired to
Batcher. Please add a brief doc comment clarifying that this toggles the order of applying sorters (affecting tie-breaker priority), distinct fromreverse_sorterwhich flips the final ordering direction.Optionally, consider a slightly clearer name like
apply_sorters_in_reversefor readability; current name is accurate but a bit heavy.Example:
- pub fn reversed_sorter_apply_order(mut self, flag: bool) -> Self { + /// If true, apply sorters in reverse declaration order (last → first) when comparing. + /// This changes tie-breaker priority among sorters. Default is false. + pub fn reversed_sorter_apply_order(mut self, flag: bool) -> Self { self.batcher.reversed_sorter_apply_order = flag; self }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/launcher.rs(1 hunks)src/launcher/batcher.rs(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/launcher/batcher.rs (2)
src/sorter.rs (3)
compare(6-6)compare(31-33)compare(58-60)src/launcher.rs (1)
reverse_sorter(180-183)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: review (ubuntu-latest)
- GitHub Check: bench (ubuntu-latest)
- GitHub Check: test (ubuntu-latest)
- GitHub Check: lint (ubuntu-latest)
🔇 Additional comments (1)
src/launcher/batcher.rs (1)
174-174: LGTM: explicit fallback toOrdering::EqualClear and correct fallback when all sorters return equality.
Summary by CodeRabbit