Check insert optimization for bank_forks (#24641)

* check insert optimization

* clippy suggested simplification
This commit is contained in:
HaoranYi 2022-04-25 19:17:21 -05:00 committed by GitHub
parent 12ae8d3be5
commit 9044cd7179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -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();