⚡️ Remove useless clone - #486
Merged
Merged
Conversation
This was referenced May 9, 2025
Member
Author
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
May 12, 2025 08:47
a514ee5 to
1e5802c
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 12, 2025 08:47
a4df891 to
4390d0e
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
May 12, 2025 08:49
1e5802c to
a4afbb3
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 12, 2025 08:49
4390d0e to
eeada01
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
May 12, 2025 08:58
a4afbb3 to
f6c04d2
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 12, 2025 11:36
eeada01 to
e7ffa1b
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
May 12, 2025 11:36
f6c04d2 to
7e9c5ce
Compare
This was referenced May 12, 2025
There was a problem hiding this comment.
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 {
dastansam
approved these changes
May 19, 2025
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 19, 2025 06:15
e7ffa1b to
b5652c4
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
2 times, most recently
from
May 19, 2025 06:48
8b86a93 to
b244067
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 19, 2025 06:48
b5652c4 to
2db9c76
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
May 20, 2025 06:21
b244067 to
e9c508f
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 20, 2025 06:21
2db9c76 to
c9be272
Compare
dastansam
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
May 23, 2025 11:43
e9c508f to
1e2f49d
Compare
Closed
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 28, 2025 13:35
156f866 to
e22ac65
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
2 times, most recently
from
May 28, 2025 13:38
093bd7c to
bda4556
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
May 28, 2025 13:38
e22ac65 to
378a176
Compare
dastansam
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
July 9, 2025 06:38
bda4556 to
18ad867
Compare
dastansam
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
July 9, 2025 06:38
378a176 to
48db973
Compare
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
July 25, 2025 14:19
18ad867 to
f6c2185
Compare
lrazovic
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
July 25, 2025 14:19
48db973 to
d4e10e0
Compare
dastansam
force-pushed
the
05-09-feat_simplify_the_acceptable_assets
branch
from
July 25, 2025 21:21
d4e10e0 to
48db973
Compare
dastansam
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
July 25, 2025 21:21
f6c2185 to
18ad867
Compare
Member
Author
lrazovic
changed the base branch from
05-09-feat_simplify_the_acceptable_assets
to
graphite-base/486
August 4, 2025 07:53
lrazovic
force-pushed
the
05-09-chore_remove_useless_clone
branch
from
August 4, 2025 07:56
18ad867 to
76d75a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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]