Skip to content
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

fix: avoid cloning double reference & remove unnecessary clone #3853

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions stackslib/src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5580,9 +5580,7 @@ impl<'a> SortitionHandleTx<'a> {
hash_tied.sort();
let winner = hash_tied
.first()
.as_ref()
.expect("FATAL: zero-length list of tied block IDs")
.clone();
.expect("FATAL: zero-length list of tied block IDs");
let winner_index = *mapping
.get(&winner)
.expect("FATAL: winning block ID not mapped");
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/coordinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ pub fn setup_states_with_epochs(
burnchain_blocks_db,
first_sortition.burn_header_hash,
registers,
path.clone(),
*path,
));
} else {
others.push(burnchain_blocks_db);
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl TestMinerTrace {
let mut all_test_names = HashSet::new();
for p in self.points.iter() {
for miner_id in p.miner_node_map.keys() {
if let Some(ref test_name) = p.miner_node_map.get(miner_id) {
if let Some(test_name) = p.miner_node_map.get(miner_id) {
if !all_test_names.contains(test_name) {
all_test_names.insert(test_name.clone());
}
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/clarity_vm/database/marf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl MarfedKV {
) -> InterpreterResult<MarfedKV> {
let marf = MarfedKV::setup_db(path_str, false, marf_opts)?;
let chain_tip = match miner_tip {
Some(ref miner_tip) => *miner_tip.clone(),
Some(miner_tip) => miner_tip.clone(),
None => StacksBlockId::sentinel(),
};

Expand All @@ -102,7 +102,7 @@ impl MarfedKV {
) -> InterpreterResult<MarfedKV> {
let marf = MarfedKV::setup_db(path_str, true, marf_opts)?;
let chain_tip = match miner_tip {
Some(ref miner_tip) => *miner_tip.clone(),
Some(miner_tip) => miner_tip.clone(),
None => StacksBlockId::sentinel(),
};

Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ impl ConversationP2P {
chain_view: &BurnchainView,
) -> bool {
let bhh = match chain_view.last_burn_block_hashes.get(&block_height) {
Some(ref bhh) => bhh.clone(),
Some(bhh) => bhh,
None => {
// not present; can't prove disagreement (assume the remote peer is just stale)
return false;
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/neighbors/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl<DB: NeighborWalkDB, NC: NeighborComms> NeighborWalk<DB, NC> {
);

let (addr, pingback_peer) = match network.get_walk_pingbacks().iter().skip(idx).next() {
Some((ref addr, ref pingback_peer)) => (addr.clone(), pingback_peer.clone()),
Some((addr, pingback_peer)) => (addr, pingback_peer),
None => {
return Err(net_error::NoSuchNeighbor);
}
Expand Down