Skip to content

Commit

Permalink
Uses while-let (solana-labs#32479)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored and pull[bot] committed Nov 8, 2023
1 parent 55ed51d commit 1b310db
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
6 changes: 2 additions & 4 deletions core/src/consensus/heaviest_subtree_fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ impl HeaviestSubtreeForkChoice {
let mut tree_root = None;
// Find the subtrees to prune
let mut to_visit = vec![self.tree_root];
while !to_visit.is_empty() {
let cur_slot = to_visit.pop().unwrap();
while let Some(cur_slot) = to_visit.pop() {
if cur_slot == new_root {
tree_root = Some(new_root);
continue;
Expand Down Expand Up @@ -532,8 +531,7 @@ impl HeaviestSubtreeForkChoice {
let mut split_tree_fork_infos = HashMap::new();
let mut to_visit = vec![*slot_hash_key];

while !to_visit.is_empty() {
let current_node = to_visit.pop().unwrap();
while let Some(current_node) = to_visit.pop() {
let current_fork_info = self
.fork_infos
.remove(&current_node)
Expand Down
3 changes: 1 addition & 2 deletions core/src/consensus/tree_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ pub trait TreeDiff<'a> {
}
let mut pending_keys = vec![root1];
let mut reachable_set = HashSet::new();
while !pending_keys.is_empty() {
let current_key = pending_keys.pop().unwrap();
while let Some(current_key) = pending_keys.pop() {
if current_key == root2 {
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/verified_vote_packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ impl<'a> Iterator for ValidatorGossipVotesIterator<'a> {

fn next(&mut self) -> Option<Self::Item> {
use SingleValidatorVotes::*;
while !self.vote_account_keys.is_empty() {
let vote_account_key = self.vote_account_keys.pop().unwrap();
while let Some(vote_account_key) = self.vote_account_keys.pop() {
// Get all the gossip votes we've queued up for this validator
// that are:
// 1) missing from the current leader bank
Expand Down
3 changes: 1 addition & 2 deletions local-cluster/src/cluster_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ pub fn verify_ledger_ticks(ledger_path: &Path, ticks_per_slot: usize) {
.into_iter()
.map(|slot| (slot, 0, last_id))
.collect();
while !pending_slots.is_empty() {
let (slot, parent_slot, last_id) = pending_slots.pop().unwrap();
while let Some((slot, parent_slot, last_id)) = pending_slots.pop() {
let next_slots = ledger
.get_slots_since(&[slot])
.unwrap()
Expand Down

0 comments on commit 1b310db

Please sign in to comment.