Tiny savings via reserve
parent
64aa0520ed
commit
d9e8c0526d
|
@ -65,6 +65,7 @@ HybridBayesNet HybridBayesNet::prune(
|
||||||
}
|
}
|
||||||
|
|
||||||
HybridBayesNet result;
|
HybridBayesNet result;
|
||||||
|
result.reserve(size());
|
||||||
|
|
||||||
// Go through all the Gaussian conditionals, restrict them according to
|
// Go through all the Gaussian conditionals, restrict them according to
|
||||||
// fixed values, and then prune further.
|
// fixed values, and then prune further.
|
||||||
|
@ -84,9 +85,9 @@ HybridBayesNet HybridBayesNet::prune(
|
||||||
}
|
}
|
||||||
// Type-erase and add to the pruned Bayes Net fragment.
|
// Type-erase and add to the pruned Bayes Net fragment.
|
||||||
result.push_back(prunedHybridGaussianConditional);
|
result.push_back(prunedHybridGaussianConditional);
|
||||||
} else if (auto gc = conditional->asGaussian()) {
|
} else if (conditional->isContinuous()) {
|
||||||
// Add the non-HybridGaussianConditional conditional
|
// Add the non-Hybrid GaussianConditional conditional
|
||||||
result.push_back(gc);
|
result.push_back(conditional);
|
||||||
} else
|
} else
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"HybrdiBayesNet::prune: Unknown HybridConditional type.");
|
"HybrdiBayesNet::prune: Unknown HybridConditional type.");
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace gtsam {
|
||||||
KeyVector CollectKeys(const KeyVector &continuousKeys,
|
KeyVector CollectKeys(const KeyVector &continuousKeys,
|
||||||
const DiscreteKeys &discreteKeys) {
|
const DiscreteKeys &discreteKeys) {
|
||||||
KeyVector allKeys;
|
KeyVector allKeys;
|
||||||
|
allKeys.reserve(continuousKeys.size() + discreteKeys.size());
|
||||||
std::copy(continuousKeys.begin(), continuousKeys.end(),
|
std::copy(continuousKeys.begin(), continuousKeys.end(),
|
||||||
std::back_inserter(allKeys));
|
std::back_inserter(allKeys));
|
||||||
std::transform(discreteKeys.begin(), discreteKeys.end(),
|
std::transform(discreteKeys.begin(), discreteKeys.end(),
|
||||||
|
@ -34,6 +35,7 @@ KeyVector CollectKeys(const KeyVector &continuousKeys,
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
KeyVector CollectKeys(const KeyVector &keys1, const KeyVector &keys2) {
|
KeyVector CollectKeys(const KeyVector &keys1, const KeyVector &keys2) {
|
||||||
KeyVector allKeys;
|
KeyVector allKeys;
|
||||||
|
allKeys.reserve(keys1.size() + keys2.size());
|
||||||
std::copy(keys1.begin(), keys1.end(), std::back_inserter(allKeys));
|
std::copy(keys1.begin(), keys1.end(), std::back_inserter(allKeys));
|
||||||
std::copy(keys2.begin(), keys2.end(), std::back_inserter(allKeys));
|
std::copy(keys2.begin(), keys2.end(), std::back_inserter(allKeys));
|
||||||
return allKeys;
|
return allKeys;
|
||||||
|
|
Loading…
Reference in New Issue