diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index bdb870a02..9786d5070 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -615,7 +615,7 @@ impl<'a> InvokeContext<'a> { pub fn get_syscall_context(&self) -> Result<&SyscallContext, InstructionError> { self.syscall_context .last() - .and_then(|syscall_context| syscall_context.as_ref()) + .and_then(std::option::Option::as_ref) .ok_or(InstructionError::CallDepth) } diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index 037de2497..b88a79a61 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -139,7 +139,7 @@ pub struct LoadedProgram { pub maybe_expiration_slot: Option, /// How often this entry was used by a transaction pub tx_usage_counter: AtomicU64, - /// How often this entry was used by a transaction + /// How often this entry was used by an instruction pub ix_usage_counter: AtomicU64, } @@ -371,7 +371,7 @@ impl LoadedProgram { effective_slot: self.effective_slot, maybe_expiration_slot: self.maybe_expiration_slot, tx_usage_counter: AtomicU64::new(self.tx_usage_counter.load(Ordering::Relaxed)), - ix_usage_counter: AtomicU64::new(self.tx_usage_counter.load(Ordering::Relaxed)), + ix_usage_counter: AtomicU64::new(self.ix_usage_counter.load(Ordering::Relaxed)), }) } @@ -646,14 +646,9 @@ impl LoadedPrograms { } pub fn prune_by_deployment_slot(&mut self, slot: Slot) { - self.entries.retain(|_key, second_level| { - *second_level = second_level - .iter() - .filter(|entry| entry.deployment_slot != slot) - .cloned() - .collect(); - !second_level.is_empty() - }); + for second_level in self.entries.values_mut() { + second_level.retain(|entry| entry.deployment_slot != slot); + } self.remove_programs_with_no_entries(); } @@ -917,7 +912,6 @@ impl LoadedPrograms { .len() .saturating_sub(shrink_to.apply_to(MAX_LOADED_ENTRY_COUNT)); self.unload_program_entries(sorted_candidates.iter().take(num_to_unload)); - self.remove_programs_with_no_entries(); } /// Removes all the entries at the given keys, if they exist @@ -929,7 +923,7 @@ impl LoadedPrograms { fn unload_program(&mut self, id: &Pubkey) { if let Some(entries) = self.entries.get_mut(id) { - entries.iter_mut().for_each(|entry| { + for entry in entries.iter_mut() { if let Some(unloaded) = entry.to_unloaded() { *entry = Arc::new(unloaded); self.stats @@ -938,7 +932,7 @@ impl LoadedPrograms { .and_modify(|c| saturating_add_assign!(*c, 1)) .or_insert(1); } - }); + } } } @@ -1131,7 +1125,6 @@ mod tests { #[test] fn test_eviction() { let mut programs = vec![]; - let mut num_total_programs: usize = 0; let mut cache = new_mock_cache::(); @@ -1151,7 +1144,6 @@ mod tests { AtomicU64::new(usage_counter), ), ); - num_total_programs += 1; programs.push((program1, *deployment_slot, usage_counter)); }); @@ -1185,7 +1177,6 @@ mod tests { AtomicU64::new(usage_counter), ), ); - num_total_programs += 1; programs.push((program2, *deployment_slot, usage_counter)); }); @@ -1218,7 +1209,6 @@ mod tests { AtomicU64::new(usage_counter), ), ); - num_total_programs += 1; programs.push((program3, *deployment_slot, usage_counter)); });