-
Notifications
You must be signed in to change notification settings - Fork 9
⚡️ Remove useless clone #486
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
a514ee5 to
1e5802c
Compare
a4df891 to
4390d0e
Compare
1e5802c to
a4afbb3
Compare
4390d0e to
eeada01
Compare
a4afbb3 to
f6c04d2
Compare
eeada01 to
e7ffa1b
Compare
f6c04d2 to
7e9c5ce
Compare
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.
Pull Request Overview
This PR removes unnecessary .clone() calls and marks simple constructors and accessors as const fn to enforce immutability at compile time, while tightening the redundant_clone lint.
- Removed redundant
clone()calls across runtime and pallet code. - Added
const fnqualifiers to simple constructors and methods. - Updated
Cargo.tomlto deny redundant clones and warn on missingconst fn.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| runtimes/polimec/src/xcm_config.rs | Removed useless clone and switched to is_some_and |
| polimec-common/common/src/lib.rs | Made from(Vec<>) constructor a const fn |
| pallets/proxy-bonding/src/functions.rs | Removed redundant .clone() on treasury and account parameters |
| pallets/on-slash-vesting/src/lib.rs | Changed on_slash to take &Balance and updated usages |
| pallets/linear-release/src/lib.rs | Converted max_vesting_schedules to const fn |
| pallets/funding/src/types.rs | Added const fn to multiple constructors and predicate methods |
| pallets/funding/src/instantiator/types.rs | Marked all .new methods as const fn |
| pallets/funding/src/instantiator/mod.rs | Removed clippy allow for wildcard imports |
| pallets/funding/src/instantiator/chain_interactions.rs | Removed redundant clones, made new a const fn |
| pallets/funding/src/instantiator/calculations.rs | Dropped unnecessary clone before grouping bids |
| pallets/funding/src/functions/misc.rs | Removed .clone() on polimec_account |
| pallets/funding/src/functions/5_settlement.rs | Removed clones on escrow_account and slashed_amount |
| pallets/funding/src/functions/3_auction.rs | Dropped .clone() on bidder in event emission |
| pallets/funding/src/functions/1_application.rs | Removed clones on issuer and did in project creation |
| pallets/dispenser/src/extensions.rs | Made constructor from(nonce) a const fn |
| Cargo.toml | Set redundant_clone = "deny" and added missing-const-for-fn |
Comments suppressed due to low confidence (2)
pallets/funding/src/instantiator/mod.rs:15
- The wildcard imports here are no longer exempted by clippy, which may trigger lint errors. Consider replacing
*imports with specific items or re-adding a lint allowance for wildcard imports.
use crate::{traits::*, *};
pallets/funding/src/instantiator/chain_interactions.rs:15
- This
const fninvokesRefCell::new(0u64), which is not aconst fnin the standard library. It will fail to compile. Either revert to a non-const function or ensure all called functions areconst-compatible.
pub const fn new(ext: OptionalExternalities) -> Self {
e7ffa1b to
b5652c4
Compare
8b86a93 to
b244067
Compare
b5652c4 to
2db9c76
Compare
b244067 to
e9c508f
Compare
2db9c76 to
c9be272
Compare
e9c508f to
1e2f49d
Compare
156f866 to
e22ac65
Compare
093bd7c to
bda4556
Compare
e22ac65 to
378a176
Compare
bda4556 to
18ad867
Compare
378a176 to
48db973
Compare
18ad867 to
f6c2185
Compare
48db973 to
d4e10e0
Compare
d4e10e0 to
48db973
Compare
f6c2185 to
18ad867
Compare
18ad867 to
76d75a9
Compare

This pull request introduces several updates across multiple files to improve code consistency, enhance performance, and adopt best practices. Key changes include enforcing stricter linting rules, replacing redundant
.clone()calls with direct references, addingconstconstructors for better compile-time optimizations, and removing unnecessary imports. These changes aim to streamline the codebase and improve maintainability.Linting and Code Quality Improvements:
Cargo.tomlto enforce stricter linting by changingredundant_clonefrom "warn" to "deny" and adding a new lint rulemissing-const-for-fnset to "warn".Performance Optimizations:
.clone()calls with direct references or moved values where cloning was unnecessary, e.g., inpallets/funding/src/functions/1_application.rs,pallets/funding/src/functions/3_auction.rs, andpallets/funding/src/instantiator/chain_interactions.rs. [1] [2] [3]Compile-Time Improvements:
constconstructors for several structs and utility functions across the codebase, such asCheckNonce,EvaluationParams, andUserToFundingAsset, enabling compile-time evaluation where possible. [1] [2] [3]Simplification of Code:
.clone()calls in functional operations, such asgroup_byandmap, to simplify logic and reduce redundancy inpallets/funding/src/instantiator/calculations.rs. [1] [2]Miscellaneous Enhancements:
pallets/funding/src/types.rstoconstfunctions, such asusd_ticket_above_minimum_per_participationandmultiplier, to improve performance and enable compile-time checks. [1] [2]