summaryrefslogtreecommitdiffstats
path: root/searchsummary
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-10-27 11:19:13 +0200
committerHenning Baldersheim <balder@oath.com>2018-11-01 15:14:38 +0100
commitd31a1b7f2df4ea94821a9d98754f4ae186bbf2d8 (patch)
tree75515a07b65e9225ac3a43f7830d825e5cbb916d /searchsummary
parentc3982d42b9d5ca9aea7600f5bc5fc6cceb78505a (diff)
Use a templated find() to enable lookup without object creation when objects are comparable.
Diffstat (limited to 'searchsummary')
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.cpp14
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.h6
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp9
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/resultclass.h6
4 files changed, 18 insertions, 17 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.cpp b/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.cpp
index d75ca47dd33..79266d34585 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.cpp
@@ -4,6 +4,7 @@
#include "keywordextractor.h"
#include "idocsumenvironment.h"
#include <vespa/searchlib/parsequery/stackdumpiterator.h>
+#include <vespa/vespalib/stllike/hashtable.hpp>
/** Tell us what parts of the query we are interested in */
@@ -12,12 +13,7 @@ namespace search::docsummary {
bool useful(search::ParseItem::ItemCreator creator)
{
- switch (creator) {
- case search::ParseItem::CREA_ORIG:
- return true;
- default:
- return false;
- }
+ return creator == search::ParseItem::CREA_ORIG;
}
@@ -38,6 +34,12 @@ KeywordExtractor::~KeywordExtractor()
}
}
+bool
+KeywordExtractor::IsLegalIndexName(const char *idxName) const
+{
+ return _legalIndexes.find(idxName) != _legalIndexes.end();
+}
+
KeywordExtractor::IndexPrefix::IndexPrefix(const char *prefix, IndexPrefix **list)
: _prefix(NULL),
_prefixLen(0),
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.h b/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.h
index 6c9ed675225..cfc73d606a0 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/keywordextractor.h
@@ -51,11 +51,7 @@ private:
return false;
}
- bool IsLegalIndexName(const char *idxName) const
- {
- return _legalIndexes.find(idxName) != _legalIndexes.end();
- }
-
+ bool IsLegalIndexName(const char *idxName) const;
public:
explicit KeywordExtractor(IDocsumEnvironment * env);
~KeywordExtractor();
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp
index 507ec7b3866..8066a5e65db 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp
@@ -2,6 +2,7 @@
#include "resultclass.h"
#include "resultconfig.h"
+#include <vespa/vespalib/stllike/hashtable.hpp>
#include <cassert>
#include <zlib.h>
@@ -18,8 +19,14 @@ ResultClass::ResultClass(const char *name, uint32_t id, util::StringEnum & field
{ }
-ResultClass::~ResultClass() { }
+ResultClass::~ResultClass() = default;
+int
+ResultClass::GetIndexFromName(const char* name) const
+{
+ NameIdMap::const_iterator found(_nameMap.find(name));
+ return (found != _nameMap.end()) ? found->second : -1;
+}
bool
ResultClass::AddConfigEntry(const char *name, ResType type)
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h
index d1504ed5bdd..e7c7c799b5f 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h
@@ -245,11 +245,7 @@ public:
*
* @return field index or -1 if not found.
**/
- int GetIndexFromName(const char* name) const
- {
- NameIdMap::const_iterator found(_nameMap.find(name));
- return (found != _nameMap.end()) ? found->second : -1;
- }
+ int GetIndexFromName(const char* name) const;
/**