diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-25 18:00:28 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-25 18:00:28 +0000 |
commit | bc176ca582e95f731071f46c9bb26aa1538fbdeb (patch) | |
tree | 25f490413d0107f15faa4167816d760e6a9d7c76 /searchcore | |
parent | 7dcb1520105b85473909d081d1ce0e139dfd38c8 (diff) |
Avoid frequent dynamic_cast to check if a node is an intermediate.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/query.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index 52274b1be94..1bb521a693e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -64,11 +64,14 @@ find_location_terms(Node *tree) { std::vector<ProtonLocationTerm *> retval; std::vector<Node *> nodes; nodes.push_back(tree); + // Note the nodes vector being iterated over is appended in the loop for (size_t i = 0; i < nodes.size(); ++i) { - if (auto loc = dynamic_cast<ProtonLocationTerm *>(nodes[i])) { + Node * node = nodes[i]; + if (auto loc = dynamic_cast<ProtonLocationTerm *>(node)) { retval.push_back(loc); } - if (auto parent = dynamic_cast<const search::query::Intermediate *>(nodes[i])) { + if (node->isIntermediate()) { + auto parent = static_cast<const search::query::Intermediate *>(node); for (Node * child : parent->getChildren()) { nodes.push_back(child); } |