Remove redundant clones (#31685)

* broadcast_stage remove redundant clone

* broadcast_fake_shreds_run remove redundant clone

* wallet remove redundant clone

* cluster_query remove redundant clone

* accounts remove redundant clones
This commit is contained in:
Andrew Fitzgerald 2023-05-23 09:42:05 -07:00 committed by GitHub
parent 02ac8a46d6
commit 5448d0b1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 21 deletions

View File

@ -1109,7 +1109,7 @@ pub fn process_get_epoch_info(rpc_client: &RpcClient, config: &CliConfig) -> Pro
match config.output_format {
OutputFormat::Json | OutputFormat::JsonCompact => {}
_ => {
let epoch_info = cli_epoch_info.epoch_info.clone();
let epoch_info = &cli_epoch_info.epoch_info;
let average_slot_time_ms = rpc_client
.get_recent_performance_samples(Some(60))
.ok()

View File

@ -651,7 +651,7 @@ pub fn process_show_account(
use_lamports_unit: bool,
) -> ProcessResult {
let account = rpc_client.get_account(account_pubkey)?;
let data = account.data.clone();
let data = &account.data;
let cli_account = CliAccount::new(account_pubkey, &account, use_lamports_unit);
let mut account_string = config.output_format.formatted_string(&cli_account);
@ -668,7 +668,7 @@ pub fn process_show_account(
OutputFormat::Display | OutputFormat::DisplayVerbose => {
if let Some(output_file) = output_file {
let mut f = File::create(output_file)?;
f.write_all(&data)?;
f.write_all(data)?;
writeln!(&mut account_string)?;
writeln!(&mut account_string, "Wrote account data to {output_file}")?;
} else if !data.is_empty() {

View File

@ -651,7 +651,7 @@ pub mod test {
let ticks_per_slot;
let slot;
{
let bank = broadcast_service.bank.clone();
let bank = broadcast_service.bank;
start_tick_height = bank.tick_height();
max_tick_height = bank.max_tick_height();
ticks_per_slot = bank.ticks_per_slot();

View File

@ -37,7 +37,7 @@ impl BroadcastRun for BroadcastFakeShredsRun {
) -> Result<()> {
// 1) Pull entries from banking stage
let receive_results = broadcast_utils::recv_slot_entries(receiver)?;
let bank = receive_results.bank.clone();
let bank = receive_results.bank;
let last_tick_height = receive_results.last_tick_height;
let next_shred_index = blockstore

View File

@ -2977,24 +2977,20 @@ mod tests {
let counter_clone = counter.clone();
let accounts_clone = accounts_arc.clone();
let exit_clone = exit.clone();
thread::spawn(move || {
let counter_clone = counter_clone.clone();
let exit_clone = exit_clone.clone();
loop {
let txs = vec![writable_tx.clone()];
let results = accounts_clone
.clone()
.lock_accounts(txs.iter(), MAX_TX_ACCOUNT_LOCKS);
for result in results.iter() {
if result.is_ok() {
counter_clone.clone().fetch_add(1, Ordering::SeqCst);
}
}
accounts_clone.unlock_accounts(txs.iter(), &results);
if exit_clone.clone().load(Ordering::Relaxed) {
break;
thread::spawn(move || loop {
let txs = vec![writable_tx.clone()];
let results = accounts_clone
.clone()
.lock_accounts(txs.iter(), MAX_TX_ACCOUNT_LOCKS);
for result in results.iter() {
if result.is_ok() {
counter_clone.clone().fetch_add(1, Ordering::SeqCst);
}
}
accounts_clone.unlock_accounts(txs.iter(), &results);
if exit_clone.clone().load(Ordering::Relaxed) {
break;
}
});
let counter_clone = counter;
for _ in 0..5 {