diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-25 19:49:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 19:49:47 +0100 |
commit | a77eedb743ee2cbc4241816545952be8e033b070 (patch) | |
tree | 6759bdcce017559f17687588139245583e5ab324 /searchcore | |
parent | 3b42e096939de8b95a10015765d949e53f8ca15c (diff) | |
parent | bc176ca582e95f731071f46c9bb26aa1538fbdeb (diff) |
Merge pull request #17187 from vespa-engine/balder/avoid-dynamic_cast-for-intermediates
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); } |