aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-07-17 18:21:54 +0200
committerHenning Baldersheim <balder@oath.com>2018-07-17 18:21:54 +0200
commit2768ed6a3061c2c2c6d2ae8ec9821941c7f65422 (patch)
tree7fe0fa832e92d42ca2eefe6c4512bfc7b1024a2c
parentfc8907289a23c1f5dc10da18f7e48d6b572aaa88 (diff)
- std::make_xxx
- c++11 for loop
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matcher.cpp15
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/matchview.cpp8
2 files changed, 12 insertions, 11 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
index 8de03411ea3..add4351f90b 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
@@ -56,9 +56,10 @@ FeatureSet::SP
findFeatureSet(const DocsumRequest &req, MatchToolsFactory &mtf, bool summaryFeatures)
{
std::vector<uint32_t> docs;
- for (size_t i = 0; i < req.hits.size(); ++i) {
- if (req.hits[i].docid != search::endDocId) {
- docs.push_back(req.hits[i].docid);
+ docs.reserve(req.hits.size());
+ for (const auto & hit : req.hits) {
+ if (hit.docid != search::endDocId) {
+ docs.push_back(hit.docid);
}
}
std::sort(docs.begin(), docs.end());
@@ -102,7 +103,7 @@ Matcher::getFeatureSet(const DocsumRequest & req, ISearchContext & searchCtx, IA
bool searchSessionCached = cache_props.lookup("query").found();
if (searchSessionCached) {
SearchSession::SP session(sessionMgr.pickSearch(sessionId));
- if (session.get()) {
+ if (session) {
MatchToolsFactory &mtf = session->getMatchToolsFactory();
FeatureSet::SP result = findFeatureSet(req, mtf, summaryFeatures);
session->releaseEnumGuards();
@@ -117,7 +118,7 @@ Matcher::getFeatureSet(const DocsumRequest & req, ISearchContext & searchCtx, IA
if (!mtf->valid()) {
LOG(warning, "getFeatureSet(%s): query execution failed (invalid query). Returning empty feature set",
(summaryFeatures ? "summary features" : "rank features"));
- return FeatureSet::SP(new FeatureSet());
+ return std::make_shared<FeatureSet>();
}
return findFeatureSet(req, *mtf, summaryFeatures);
}
@@ -224,14 +225,14 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl
shouldCacheSearchSession = cache_props.lookup("query").found();
if (shouldCacheGroupingSession) {
GroupingSession::UP session(sessionMgr.pickGrouping(sessionId));
- if (session.get()) {
+ if (session) {
return handleGroupingSession(sessionMgr, groupingContext, std::move(session));
}
}
}
const Properties *feature_overrides = &request.propertiesMap.featureOverrides();
if (shouldCacheSearchSession) {
- owned_objects.feature_overrides.reset(new Properties(*feature_overrides));
+ owned_objects.feature_overrides = std::make_unique<Properties>(*feature_overrides);
feature_overrides = owned_objects.feature_overrides.get();
}
MatchToolsFactory::UP mtf = create_match_tools_factory(request, searchContext, attrContext,
diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp
index 3162f9a1c45..9af648917c4 100644
--- a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp
@@ -44,13 +44,13 @@ MatchView::MatchView(const Matchers::SP &matchers,
_docIdLimit(docIdLimit)
{ }
-MatchView::~MatchView() { }
+MatchView::~MatchView() = default;
Matcher::SP
MatchView::getMatcher(const vespalib::string & rankProfile) const
{
Matcher::SP retval = _matchers->lookup(rankProfile);
- if (retval.get() == NULL) {
+ if ( ! retval) {
throw std::runtime_error(make_string("Failed locating Matcher for rank profile '%s'", rankProfile.c_str()));
}
LOG(debug, "Rankprofile = %s has termwise_limit=%f", rankProfile.c_str(), retval->get_termwise_limit());
@@ -60,8 +60,8 @@ MatchView::getMatcher(const vespalib::string & rankProfile) const
MatchContext::UP MatchView::createContext() const {
IAttributeContext::UP attrCtx = _attrMgr->createContext();
- ISearchContext::UP searchCtx(new SearchContext(_indexSearchable, _docIdLimit.get()));
- return MatchContext::UP(new MatchContext(std::move(attrCtx), std::move(searchCtx)));
+ auto searchCtx = std::make_unique<SearchContext>(_indexSearchable, _docIdLimit.get());
+ return std::make_unique<MatchContext>(std::move(attrCtx), std::move(searchCtx));
}