summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-09-03 05:24:00 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-09-03 09:31:52 +0000
commit77a4c434005430aa69146375b576f52294bfe742 (patch)
tree733d13692a4fe8b7ab03d5aa607a75306964e564 /searchlib
parenta41c6717c20cd547b539bd2c387efe54c8bb8ef4 (diff)
std::make_unique and c++11 for loops.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp23
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h7
2 files changed, 11 insertions, 19 deletions
diff --git a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp
index 5cd74229fce..e3588d88ccb 100644
--- a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp
@@ -32,10 +32,10 @@ CreateBlueprintVisitorHelper::getResult()
void
CreateBlueprintVisitorHelper::visitPhrase(query::Phrase &n) {
auto phrase = std::make_unique<SimplePhraseBlueprint>(_field, _requestContext);
- for (size_t i = 0; i < n.getChildren().size(); ++i) {
+ for (const query::Node * child : n.getChildren()) {
FieldSpecList fields;
fields.add(phrase->getNextChildField(_field));
- phrase->addTerm(_searchable.createBlueprint(_requestContext, fields, *n.getChildren()[i]));
+ phrase->addTerm(_searchable.createBlueprint(_requestContext, fields, *child));
}
setResult(std::move(phrase));
}
@@ -64,8 +64,7 @@ CreateBlueprintVisitorHelper::handleNumberTermAsText(query::NumberTerm &n)
template <typename WS, typename NODE>
void
-CreateBlueprintVisitorHelper::createWeightedSet(WS *bp, NODE &n) {
- Blueprint::UP result(bp);
+CreateBlueprintVisitorHelper::createWeightedSet(std::unique_ptr<WS> bp, NODE &n) {
FieldSpecList fields;
for (size_t i = 0; i < n.getChildren().size(); ++i) {
fields.clear();
@@ -74,25 +73,21 @@ CreateBlueprintVisitorHelper::createWeightedSet(WS *bp, NODE &n) {
uint32_t weight = getWeightFromNode(node).percent();
bp->addTerm(_searchable.createBlueprint(_requestContext, fields, node), weight);
}
- setResult(std::move(result));
+ setResult(std::move(bp));
}
void
CreateBlueprintVisitorHelper::visitWeightedSetTerm(query::WeightedSetTerm &n) {
- WeightedSetTermBlueprint *bp = new WeightedSetTermBlueprint(_field);
- createWeightedSet(bp, n);
+ createWeightedSet(std::make_unique<WeightedSetTermBlueprint>(_field), n);
}
void
CreateBlueprintVisitorHelper::visitDotProduct(query::DotProduct &n) {
- DotProductBlueprint *bp = new DotProductBlueprint(_field);
- createWeightedSet(bp, n);
+ createWeightedSet(std::make_unique<DotProductBlueprint>(_field), n);
}
void
CreateBlueprintVisitorHelper::visitWandTerm(query::WandTerm &n) {
- ParallelWeakAndBlueprint *bp = new ParallelWeakAndBlueprint(_field,
- n.getTargetNumHits(),
- n.getScoreThreshold(),
- n.getThresholdBoostFactor());
- createWeightedSet(bp, n);
+ createWeightedSet(std::make_unique<ParallelWeakAndBlueprint>(_field, n.getTargetNumHits(),
+ n.getScoreThreshold(), n.getThresholdBoostFactor()),
+ n);
}
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h
index 5bcc4f4c4c5..84830111fde 100644
--- a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h
+++ b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h
@@ -25,10 +25,7 @@ protected:
public:
CreateBlueprintVisitorHelper(Searchable &searchable, const FieldSpec &field, const IRequestContext & requestContext);
- ~CreateBlueprintVisitorHelper();
-
- template <typename T>
- std::unique_ptr<T> make_UP(T *p) { return std::unique_ptr<T>(p); }
+ ~CreateBlueprintVisitorHelper() override;
template <typename T>
void setResult(std::unique_ptr<T> result) { _result = std::move(result); }
@@ -40,7 +37,7 @@ public:
void visitPhrase(query::Phrase &n);
template <typename WS, typename NODE>
- void createWeightedSet(WS *bp, NODE &n);
+ void createWeightedSet(std::unique_ptr<WS> bp, NODE &n);
void visitWeightedSetTerm(query::WeightedSetTerm &n);
void visitDotProduct(query::DotProduct &n);
void visitWandTerm(query::WandTerm &n);