Use unwrap_or_else for efficiency (#31747)
Use unwrap_or_else for efficiency.
This commit is contained in:
parent
2549bff59c
commit
917f3d2586
|
@ -2118,7 +2118,7 @@ impl ReplayStage {
|
|||
.map_or(false, |sender| sender.should_send_parents)
|
||||
.then(|| {
|
||||
let mut new_chain = rooted_slots.clone();
|
||||
new_chain.push(oldest_parent.unwrap_or(bank.parent_slot()));
|
||||
new_chain.push(oldest_parent.unwrap_or_else(|| bank.parent_slot()));
|
||||
new_chain
|
||||
});
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ mod tests {
|
|||
let oldest_parent = parents.last().map(|last| last.parent_slot());
|
||||
parents.push(bank.clone());
|
||||
let mut rooted_slots: Vec<_> = parents.iter().map(|bank| bank.slot()).collect();
|
||||
rooted_slots.push(oldest_parent.unwrap_or(bank.parent_slot()));
|
||||
rooted_slots.push(oldest_parent.unwrap_or_else(|| bank.parent_slot()));
|
||||
rooted_slots
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue