summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-25 18:49:33 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-03-25 18:50:59 +0000
commitef7cb2b999436c7cf2939ba876b3e2c675824a7a (patch)
tree87f05df7c76cf2bbebc64ddb1036cb8c6b1b2692 /searchcore
parenta77eedb743ee2cbc4241816545952be8e033b070 (diff)
Avoid dynamic_cast to select location nodes.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 1bb521a693e..d8597bd133c 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -36,6 +36,7 @@ using search::queryeval::IntermediateBlueprint;
using search::queryeval::Blueprint;
using search::queryeval::IRequestContext;
using search::queryeval::SearchIterator;
+using search::query::LocationTerm;
using vespalib::string;
using std::vector;
@@ -59,16 +60,16 @@ inject(Node::UP query, Node::UP to_inject) {
return query;
}
-std::vector<ProtonLocationTerm *>
+std::vector<LocationTerm *>
find_location_terms(Node *tree) {
- std::vector<ProtonLocationTerm *> retval;
+ std::vector<LocationTerm *> 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) {
Node * node = nodes[i];
- if (auto loc = dynamic_cast<ProtonLocationTerm *>(node)) {
- retval.push_back(loc);
+ if (node->isLocationTerm() ) {
+ retval.push_back(static_cast<LocationTerm *>(node));
}
if (node->isIntermediate()) {
auto parent = static_cast<const search::query::Intermediate *>(node);
@@ -95,7 +96,7 @@ GeoLocationSpec parse_location_string(string str) {
return empty;
}
-GeoLocationSpec process_location_term(ProtonLocationTerm &pterm) {
+GeoLocationSpec process_location_term(LocationTerm &pterm) {
auto old_view = pterm.getView();
auto new_view = PositionDataType::getZCurveFieldName(old_view);
pterm.setView(new_view);
@@ -117,7 +118,7 @@ void exchange_location_nodes(const string &location_str,
if (parsed.location.valid()) {
locationSpecs.push_back(parsed);
}
- for (ProtonLocationTerm * pterm : find_location_terms(query_tree.get())) {
+ for (LocationTerm * pterm : find_location_terms(query_tree.get())) {
auto spec = process_location_term(*pterm);
if (spec.location.valid()) {
locationSpecs.push_back(spec);