summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-25 19:49:47 +0100
committerGitHub <noreply@github.com>2021-03-25 19:49:47 +0100
commita77eedb743ee2cbc4241816545952be8e033b070 (patch)
tree6759bdcce017559f17687588139245583e5ab324 /searchcore
parent3b42e096939de8b95a10015765d949e53f8ca15c (diff)
parentbc176ca582e95f731071f46c9bb26aa1538fbdeb (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.cpp7
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);
}