Conversation
Summary of ChangesHello @waruqi, 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! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces parallel execution for the clang-format plugin, which is a great performance enhancement. It adds a new --jobs option to control the number of parallel formatting jobs. The implementation correctly uses runjobs for parallelization. I've included one suggestion to improve the robustness of handling the --jobs option value to ensure it correctly falls back to the default when an invalid value is provided. Overall, this is a valuable improvement.
xmake/plugins/format/main.lua
Outdated
| local jobs = option.get("jobs") | ||
| if jobs then | ||
| jobs = tonumber(jobs) | ||
| else | ||
| jobs = os.default_njob() | ||
| end |
There was a problem hiding this comment.
The current logic for determining the number of jobs is not fully robust. If a user provides a non-numeric value for the --jobs option (e.g., xmake format -j foo), tonumber() will return nil. The jobs variable will become nil, and runjobs will be called with comax = nil, likely falling back to a hardcoded default inside runjobs instead of using os.default_njob().
Additionally, since a default value is always provided for the jobs option, option.get("jobs") will never be nil, making the else block unreachable (dead code).
A more robust approach would be to convert the option value to a number and then check if the result is a valid positive number.
local jobs = tonumber(option.get("jobs"))
if not jobs or jobs <= 0 then
jobs = os.default_njob()
end
#6640