summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoonsoo Kim <yoonsoo.kim@mongodb.com>2021-03-05 17:01:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-10 18:04:21 +0000
commit4c74e17d5c2166e1347244652bd3ba7d50d034ef (patch)
tree480c4973c9b875a7dd38ac9df46b7330265d9e0a
parent57a2ffffd006367418f736296138c7119ba0d9d0 (diff)
downloadmongo-4c74e17d5c2166e1347244652bd3ba7d50d034ef.tar.gz
SERVER-54836 Cleaned up a few of static_cast<bool> and has_value() calls
-rw-r--r--src/mongo/db/exec/sbe/stages/ix_scan.cpp5
-rw-r--r--src/mongo/db/exec/sbe/stages/scan.cpp4
-rw-r--r--src/mongo/db/query/plan_explainer_impl.cpp11
-rw-r--r--src/mongo/db/query/sbe_stage_builder.cpp2
-rw-r--r--src/mongo/db/query/sbe_stage_builder_filter.cpp12
5 files changed, 12 insertions, 22 deletions
diff --git a/src/mongo/db/exec/sbe/stages/ix_scan.cpp b/src/mongo/db/exec/sbe/stages/ix_scan.cpp
index c5111af5329..854af856cd2 100644
--- a/src/mongo/db/exec/sbe/stages/ix_scan.cpp
+++ b/src/mongo/db/exec/sbe/stages/ix_scan.cpp
@@ -197,9 +197,8 @@ void IndexScanStage::open(bool reOpen) {
if (_open) {
tassert(5071006, "reopened IndexScanStage but reOpen=false", reOpen);
- tassert(5071007, "IndexScanStage is open but _coll is not held", _coll.has_value());
- tassert(
- 5071008, "IndexScanStage is open but don't have _cursor", static_cast<bool>(_cursor));
+ tassert(5071007, "IndexScanStage is open but _coll is not held", _coll);
+ tassert(5071008, "IndexScanStage is open but don't have _cursor", _cursor);
} else {
tassert(5071009, "first open to IndexScanStage but reOpen=true", !reOpen);
if (!_coll) {
diff --git a/src/mongo/db/exec/sbe/stages/scan.cpp b/src/mongo/db/exec/sbe/stages/scan.cpp
index 29a4950f5e4..88f1794632f 100644
--- a/src/mongo/db/exec/sbe/stages/scan.cpp
+++ b/src/mongo/db/exec/sbe/stages/scan.cpp
@@ -172,8 +172,8 @@ void ScanStage::open(bool reOpen) {
if (_open) {
tassert(5071001, "reopened ScanStage but reOpen=false", reOpen);
- tassert(5071002, "ScanStage is open but _coll is not held", _coll.has_value());
- tassert(5071003, "ScanStage is open but don't have _cursor", static_cast<bool>(_cursor));
+ tassert(5071002, "ScanStage is open but _coll is not held", _coll);
+ tassert(5071003, "ScanStage is open but don't have _cursor", _cursor);
} else {
tassert(5071004, "first open to ScanStage but reOpen=true", !reOpen);
if (!_coll) {
diff --git a/src/mongo/db/query/plan_explainer_impl.cpp b/src/mongo/db/query/plan_explainer_impl.cpp
index 0319a256e2f..5409407d67a 100644
--- a/src/mongo/db/query/plan_explainer_impl.cpp
+++ b/src/mongo/db/query/plan_explainer_impl.cpp
@@ -101,8 +101,7 @@ void flattenExecTree(const PlanStage* root, std::vector<const PlanStage*>* flatt
// Only add the winning plan from a MultiPlanStage.
auto mps = static_cast<const MultiPlanStage*>(root);
auto bestPlanIdx = mps->bestPlanIdx();
- tassert(
- 3420001, "Trying to explain MultiPlanStage without best plan", bestPlanIdx.has_value());
+ tassert(3420001, "Trying to explain MultiPlanStage without best plan", bestPlanIdx);
const auto winningStage = mps->getChildren()[*bestPlanIdx].get();
flattenExecTree(winningStage, flattened);
return;
@@ -629,9 +628,7 @@ MultiPlanStage* getMultiPlanStage(PlanStage* root) {
const boost::optional<size_t> getWinningPlanIdx(PlanStage* root) {
if (auto mps = getMultiPlanStage(root); mps) {
auto planIdx = mps->bestPlanIdx();
- tassert(3420008,
- "Trying to get stats of a MultiPlanStage without winning plan",
- planIdx.has_value());
+ tassert(3420008, "Trying to get stats of a MultiPlanStage without winning plan", planIdx);
return planIdx;
}
return {};
@@ -743,9 +740,7 @@ std::vector<PlanExplainer::PlanStatsDetails> PlanExplainerImpl::getRejectedPlans
}
auto bestPlanIdx = mps->bestPlanIdx();
- tassert(3420009,
- "Trying to get stats of a MultiPlanStage without winning plan",
- bestPlanIdx.has_value());
+ tassert(3420009, "Trying to get stats of a MultiPlanStage without winning plan", bestPlanIdx);
const auto mpsStats = mps->getStats();
// Get the stats from the trial period for all the plans.
diff --git a/src/mongo/db/query/sbe_stage_builder.cpp b/src/mongo/db/query/sbe_stage_builder.cpp
index 709fab540c7..2b1290eb54b 100644
--- a/src/mongo/db/query/sbe_stage_builder.cpp
+++ b/src/mongo/db/query/sbe_stage_builder.cpp
@@ -851,7 +851,7 @@ std::pair<std::unique_ptr<sbe::PlanStage>, PlanStageSlots> SlotBasedStageBuilder
auto indexKeys = outputs.extractIndexKeySlots();
tassert(5184302,
"SORT_MERGE must receive index key slots as input from its child stages",
- indexKeys.has_value());
+ indexKeys);
for (const auto& part : sortPattern) {
auto partPath = part.fieldPath->fullPath();
diff --git a/src/mongo/db/query/sbe_stage_builder_filter.cpp b/src/mongo/db/query/sbe_stage_builder_filter.cpp
index 29131f44569..1f475d75344 100644
--- a/src/mongo/db/query/sbe_stage_builder_filter.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_filter.cpp
@@ -1140,7 +1140,7 @@ public:
// remove the child's EvalFrame from the stack.
tassert(5273405,
"Eval frame's input slot is not defined",
- static_cast<bool>(_context->evalStack.topFrame().data().inputSlot));
+ _context->evalStack.topFrame().data().inputSlot);
auto childInputSlot = *_context->evalStack.topFrame().data().inputSlot;
auto [filterSlot, filterStage] = [&]() {
auto [expr, stage] = _context->evalStack.popFrame();
@@ -1183,7 +1183,7 @@ public:
tassert(5273406,
"Eval frame's input slot is not defined",
- static_cast<bool>(_context->evalStack.topFrame().data().inputSlot));
+ _context->evalStack.topFrame().data().inputSlot);
auto childInputSlot = *_context->evalStack.topFrame().data().inputSlot;
// Move the children's outputs off of the evalStack into a vector in preparation for
@@ -1249,12 +1249,8 @@ public:
// The $expr expression must by applied to the current $$ROOT document, so make sure that
// an input slot associated with the current frame is the same slot as the input slot for
// the entire match expression we're translating
- tassert(5273407,
- "Match expression's input slot is not defined",
- static_cast<bool>(_context->inputSlot));
- tassert(5273408,
- "Eval frame's input slot is not defined",
- static_cast<bool>(frame.data().inputSlot));
+ tassert(5273407, "Match expression's input slot is not defined", _context->inputSlot);
+ tassert(5273408, "Eval frame's input slot is not defined", frame.data().inputSlot);
tassert(5273409,
"Eval frame for $expr is not computed over expression's input slot",
*frame.data().inputSlot == *_context->inputSlot);