Skip to content

Remove unnecessary clones with clippy - #12197

Merged
crepererum merged 3 commits into
apache:mainfrom
findepi:findepi/remove-unnecessary-clones-with-clippy-e8ec70
Aug 28, 2024
Merged

Remove unnecessary clones with clippy#12197
crepererum merged 3 commits into
apache:mainfrom
findepi:findepi/remove-unnecessary-clones-with-clippy-e8ec70

Conversation

@findepi

@findepifindepi commented Aug 27, 2024

Copy link
Copy Markdown
Member

See individual commit descriptions.

@github-actionsgithub-actionsBot added sql SQL Planner logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates optimizer Optimizer rules core Core DataFusion crate execution Related to the execution crate proto Related to proto crate functions Changes to functions implementation labels Aug 27, 2024
This is automated change done with
```
cargo clippy --fix -- -Aclippy::all -Wclippy::redundant_clone
cargo fmt
# manually fix few new clippy errors introduced by clippy itself
```
Note: it doesn't remove all unnecessary clones because the command
reported error and backed out for the common crate.
@findepi
findepiforce-pushed the findepi/remove-unnecessary-clones-with-clippy-e8ec70 branch from d1c824f to 3724a74CompareAugust 27, 2024 14:51
clippy can be run with `--fix` and then it won't obey the code comment
instructing not to delete the clone.
Change code as instructed by
```
cargo clippy --fix -- -Aclippy::all -Wclippy::redundant_clone
```
where clippy didn't apply the suggested changes by itself.
@github-actionsgithub-actionsBot added the common Related to common crate label Aug 27, 2024
@findepi

Copy link
Copy Markdown
MemberAuthor

Note 1:
clippy doesn't seem to find all unnecessary clones (#12196 (comment))

Note 2
Running cargo clippy -- -Aclippy::all -Wclippy::needless_pass_by_value reports quite many functions which today move arguments but could take reference. Addressing these could potentially lead to some more cloning becoming unnecessary (and fixable with clippy). However clippy's --fix doesn't seem to work with needless_pass_by_value for me, this may require manual work. Not sure this is worth it, maybe the compiler can figure it all out on its own?

@crepererum
crepererum merged commit 8ba6732 into apache:mainAug 28, 2024
@findepi
findepi deleted the findepi/remove-unnecessary-clones-with-clippy-e8ec70 branch August 28, 2024 07:49
@findepi

Copy link
Copy Markdown
MemberAuthor

thank you @crepererum and @andygrove for review and thanks @crepererum for the merge!

BTW by any chance, do you have thoughts on needless_pass_by_value mentioned above?

@crepererum

Copy link
Copy Markdown
Contributor

BTW by any chance, do you have thoughts on needless_pass_by_value mentioned above?

I think we can tighten the linting rules for DF. In this case, add them here and fix the fall-out in the same PR:

datafusion/Cargo.toml

Lines 160 to 162 in 8ba6732

[workspace.lints.clippy]
# Detects large stack-allocated futures that may cause stack overflow crashes (see threshold in clippy.toml)
large_futures = "warn"

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commonRelated to common cratecoreCore DataFusion crateexecutionRelated to the execution cratefunctionsChanges to functions implementationlogical-exprLogical plan and expressionsoptimizerOptimizer rulesphysical-exprChanges to the physical-expr cratesprotoRelated to proto cratesqlSQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@findepi@crepererum@andygrove