From 7ad5fbf86418d2a6f17d553b5888198c5f9de05a Mon Sep 17 00:00:00 2001 From: Daniel Segel Date: Thu, 16 Jun 2022 15:55:42 +0000 Subject: SERVER-66956 Remove redundant tests in MULTI_PLAN and CACHED_PLAN --- src/mongo/db/pipeline/pipeline_d.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index ebf38ca93d6..adbca1bf973 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -1234,7 +1234,6 @@ PipelineD::buildInnerQueryExecutorGeneric(const MultipleCollectionAccessor& coll unpack && sort) { auto execImpl = dynamic_cast(exec.get()); if (execImpl) { - // Get source stage PlanStage* rootStage = execImpl->getRootStage(); while (rootStage && @@ -1247,28 +1246,27 @@ PipelineD::buildInnerQueryExecutorGeneric(const MultipleCollectionAccessor& coll case STAGE_SHARDING_FILTER: rootStage = rootStage->child().get(); break; - case STAGE_MULTI_PLAN: - if (auto mps = static_cast(rootStage)) { - if (mps->bestPlanChosen() && mps->bestPlanIdx()) { - rootStage = (mps->getChildren())[*(mps->bestPlanIdx())].get(); - } else { - rootStage = nullptr; - tasserted(6655801, - "Expected multiplanner to have selected a bestPlan."); - } + case STAGE_MULTI_PLAN: { + auto mps = static_cast(rootStage); + if (mps->bestPlanChosen() && mps->bestPlanIdx()) { + rootStage = (mps->getChildren())[*(mps->bestPlanIdx())].get(); + } else { + rootStage = nullptr; + tasserted(6655801, + "Expected multiplanner to have selected a bestPlan."); } break; - case STAGE_CACHED_PLAN: - if (auto cp = static_cast(rootStage)) { - if (cp->bestPlanChosen()) { - rootStage = rootStage->child().get(); - } else { - rootStage = nullptr; - tasserted(6655802, - "Expected cached plan to have selected a bestPlan."); - } + } + case STAGE_CACHED_PLAN: { + auto cp = static_cast(rootStage); + if (cp->bestPlanChosen()) { + rootStage = rootStage->child().get(); + } else { + rootStage = nullptr; + tasserted(6655802, "Expected cached plan to have selected a bestPlan."); } break; + } default: rootStage = nullptr; } -- cgit v1.2.1