This is a refactor that was split out of work related to #35558.
First, have_txn is redundant, since txn_available is a vector of shared_ptr:
resized:
Which means all of its members are value-initialized which for a shared_ptr means "Constructs a shared_ptr with no managed object, i.e. empty shared_ptr." and std::shared_ptr<T>::operator bool returns false for empty shared_ptr's.
In fact, the existing code already relies on this behavior:
Second,
if (a) {
b()
} else {
if(!a) {
c()
}
}
is equivalent to
if (a) {
b()
} else {
c()
}
so I make this change.