diff options
author | Henning Baldersheim <balder@oath.com> | 2018-10-27 11:19:13 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-11-01 15:14:38 +0100 |
commit | d31a1b7f2df4ea94821a9d98754f4ae186bbf2d8 (patch) | |
tree | 75515a07b65e9225ac3a43f7830d825e5cbb916d /searchcommon/src | |
parent | c3982d42b9d5ca9aea7600f5bc5fc6cceb78505a (diff) |
Use a templated find() to enable lookup without object creation when objects are comparable.
Diffstat (limited to 'searchcommon/src')
-rw-r--r-- | searchcommon/src/vespa/searchcommon/common/schema.cpp | 20 | ||||
-rw-r--r-- | searchcommon/src/vespa/searchcommon/common/schema.h | 19 |
2 files changed, 24 insertions, 15 deletions
diff --git a/searchcommon/src/vespa/searchcommon/common/schema.cpp b/searchcommon/src/vespa/searchcommon/common/schema.cpp index 5e9db03bf31..cef74409024 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.cpp +++ b/searchcommon/src/vespa/searchcommon/common/schema.cpp @@ -4,6 +4,7 @@ #include <fstream> #include <vespa/config/common/configparser.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/stllike/hashtable.hpp> #include <vespa/fastos/file.h> #include <vespa/log/log.h> @@ -421,6 +422,25 @@ Schema::getFieldSetId(vespalib::stringref name) const return getFieldId(name, _fieldSetIds); } +bool +Schema::isIndexField(vespalib::stringref name) const +{ + return _indexIds.find(name) != _indexIds.end(); +} + +bool +Schema::isSummaryField(vespalib::stringref name) const +{ + return _summaryIds.find(name) != _summaryIds.end(); +} + +bool +Schema::isAttributeField(vespalib::stringref name) const +{ + return _attributeIds.find(name) != _attributeIds.end(); +} + + void Schema::swap(Schema &rhs) { diff --git a/searchcommon/src/vespa/searchcommon/common/schema.h b/searchcommon/src/vespa/searchcommon/common/schema.h index d066ccb0a27..f8020d6ed9a 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.h +++ b/searchcommon/src/vespa/searchcommon/common/schema.h @@ -293,11 +293,7 @@ public: * @return true if field is an index field. * @param name the name of the field. **/ - bool - isIndexField(vespalib::stringref name) const - { - return _indexIds.find(name) != _indexIds.end(); - } + bool isIndexField(vespalib::stringref name) const; /** * Check if a field is a summary field @@ -305,22 +301,15 @@ public: * @return true if field is an summary field. * @param name the name of the field. **/ - bool - isSummaryField(vespalib::stringref name) const - { - return _summaryIds.find(name) != _summaryIds.end(); - } + bool isSummaryField(vespalib::stringref name) const; + /** * Check if a field is a attribute field * * @return true if field is an attribute field. * @param name the name of the field. **/ - bool - isAttributeField(vespalib::stringref name) const - { - return _attributeIds.find(name) != _attributeIds.end(); - } + bool isAttributeField(vespalib::stringref name) const; /** * Get information about a specific attribute field using the given fieldId. |