Skip to content

Commit

Permalink
Check insert optimization for bank_forks (solana-labs#24641)
Browse files Browse the repository at this point in the history
* check insert optimization

* clippy suggested simplification
  • Loading branch information
HaoranYi authored and jeffwashington committed Jun 29, 2022
1 parent c6be480 commit d408995
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions runtime/src/bank_forks.rs
Expand Up @@ -131,11 +131,10 @@ impl BankForks {
banks.insert(bank.slot(), bank.clone());
let parents = bank.parents();
for parent in parents {
if banks.contains_key(&parent.slot()) {
if banks.insert(parent.slot(), parent.clone()).is_some() {
// All ancestors have already been inserted by another fork
break;
}
banks.insert(parent.slot(), parent.clone());
}
}
let mut descendants = HashMap::<_, HashSet<_>>::new();
Expand Down

0 comments on commit d408995

Please sign in to comment.