From c79ab94eacbb6fafec8a4724ccba1c576f5f1540 Mon Sep 17 00:00:00 2001 From: Lester Solbakken Date: Fri, 1 Feb 2019 13:10:39 +0100 Subject: Use stringref instead of string --- .../vespa/searchsummary/docsummary/dynamicteaserdfw.cpp | 16 ++++++++-------- .../src/vespa/searchsummary/docsummary/juniperdfw.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp index 5888621acf9..a95c8667b7d 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp @@ -355,7 +355,7 @@ JuniperTeaserDFW::Init( return rc; } -vespalib::string +vespalib::stringref DynamicTeaserDFW::getJuniperInput(GeneralResult *gres, GetDocsumsState *state) { int idx = gres->GetClass()->GetIndexFromEnumValue(_inputFieldEnumValue); ResEntry *entry = gres->GetEntry(idx); @@ -363,13 +363,13 @@ DynamicTeaserDFW::getJuniperInput(GeneralResult *gres, GetDocsumsState *state) { const char *buf; uint32_t buflen; entry->_resolve_field(&buf, &buflen, &state->_docSumFieldSpace); - return vespalib::string(buf, buflen); + return vespalib::stringref(buf, buflen); } - return vespalib::string(); + return vespalib::stringref(); } vespalib::string -DynamicTeaserDFW::makeDynamicTeaser(uint32_t docid, vespalib::string input, GetDocsumsState *state) +DynamicTeaserDFW::makeDynamicTeaser(uint32_t docid, vespalib::stringref input, GetDocsumsState *state) { if (state->_dynteaser._query == nullptr) { JuniperQueryAdapter iq(state->_kwExtractor, @@ -401,16 +401,16 @@ DynamicTeaserDFW::makeDynamicTeaser(uint32_t docid, vespalib::string input, GetD if (LOG_WOULD_LOG(spam)) { std::ostringstream hexDump; - hexDump << vespalib::HexDump(input.c_str(), input.length()); + hexDump << vespalib::HexDump(input.data(), input.length()); LOG(spam, "makeDynamicTeaser: docid=%d, input='%s', hexdump:\n%s", - docid, input.c_str(), hexDump.str().c_str()); + docid, input.data(), hexDump.str().c_str()); } auto langid = static_cast(-1); state->_dynteaser._result = juniper::Analyse(_juniperConfig.get(), state->_dynteaser._query, - input.c_str(), input.length(), docid, _inputFieldEnumValue, langid); + input.data(), input.length(), docid, _inputFieldEnumValue, langid); } } @@ -439,7 +439,7 @@ void DynamicTeaserDFW::insertField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, ResType, vespalib::slime::Inserter &target) { - vespalib::string input = getJuniperInput(gres, state); + vespalib::stringref input = getJuniperInput(gres, state); if (input.length() > 0) { vespalib::string teaser = makeDynamicTeaser(docid, input, state); vespalib::Memory value(teaser.c_str(), teaser.size()); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/juniperdfw.h b/searchsummary/src/vespa/searchsummary/docsummary/juniperdfw.h index 5285016ec33..17beddf1e60 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/juniperdfw.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/juniperdfw.h @@ -49,9 +49,9 @@ class DynamicTeaserDFW : public JuniperTeaserDFW public: DynamicTeaserDFW(juniper::Juniper * juniper) : JuniperTeaserDFW(juniper) { } - vespalib::string getJuniperInput(GeneralResult *gres, GetDocsumsState *state); + vespalib::stringref getJuniperInput(GeneralResult *gres, GetDocsumsState *state); vespalib::string makeDynamicTeaser(uint32_t docid, - vespalib::string input, + vespalib::stringref input, GetDocsumsState *state); void insertField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, -- cgit v1.2.3