diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-25 19:05:47 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-26 13:04:01 +0000 |
commit | 40930a6ac1e0cb3a3e731884525f519024eb3ff0 (patch) | |
tree | 4dab30e65c6376883c09faa690320f5ad1c098b1 /searchcore | |
parent | f0c9bbe78ecbee2efa67a9843f39a514d5e2e901 (diff) |
Manually allocating a stack and growing is more expensive than
recursing as that is allocation free will have a smaller L1 footprint.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/query.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index d8597bd133c..51aa1db8aef 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -60,25 +60,23 @@ inject(Node::UP query, Node::UP to_inject) { return query; } -std::vector<LocationTerm *> -find_location_terms(Node *tree) { - 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 (node->isLocationTerm() ) { - retval.push_back(static_cast<LocationTerm *>(node)); - } - if (node->isIntermediate()) { - auto parent = static_cast<const search::query::Intermediate *>(node); - for (Node * child : parent->getChildren()) { - nodes.push_back(child); - } +void +find_location_terms(Node *node, std::vector<LocationTerm *> & locations) { + if (node->isLocationTerm() ) { + locations.push_back(static_cast<LocationTerm *>(node)); + } else if (node->isIntermediate()) { + auto parent = static_cast<const search::query::Intermediate *>(node); + for (Node * child : parent->getChildren()) { + find_location_terms(child, locations); } } - return retval; +} + +std::vector<LocationTerm *> +find_location_terms(Node *tree) { + std::vector<LocationTerm *> locations; + find_location_terms(tree, locations); + return locations; } GeoLocationSpec parse_location_string(string str) { |