From 822e3e3d0630b3af1d76079da8c3e1d161c3ca1a Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 10 Aug 2018 23:35:50 +0200 Subject: Pass stringref by value --- document/src/tests/documentselectparsertest.cpp | 4 +-- document/src/vespa/document/annotation/spantree.h | 2 +- document/src/vespa/document/base/field.cpp | 4 +-- document/src/vespa/document/base/field.h | 4 +-- document/src/vespa/document/base/globalid.cpp | 2 +- document/src/vespa/document/base/globalid.h | 2 +- document/src/vespa/document/base/idstring.cpp | 42 ++++++++++------------ document/src/vespa/document/base/idstring.h | 18 +++++----- .../vespa/document/datatype/collectiondatatype.cpp | 4 +-- .../vespa/document/datatype/collectiondatatype.h | 4 +-- document/src/vespa/document/datatype/datatype.cpp | 8 ++--- document/src/vespa/document/datatype/datatype.h | 4 +-- .../src/vespa/document/datatype/documenttype.cpp | 12 +++---- .../src/vespa/document/datatype/documenttype.h | 12 +++---- .../src/vespa/document/datatype/structdatatype.cpp | 8 ++--- .../src/vespa/document/datatype/structdatatype.h | 8 ++--- .../vespa/document/datatype/structureddatatype.cpp | 8 ++--- .../vespa/document/datatype/structureddatatype.h | 10 +++--- .../src/vespa/document/fieldset/fieldsetrepo.cpp | 2 +- .../document/fieldvalue/collectionfieldvalue.h | 6 ++-- .../src/vespa/document/fieldvalue/document.cpp | 4 +-- document/src/vespa/document/fieldvalue/document.h | 4 +-- .../src/vespa/document/fieldvalue/fieldvalue.cpp | 2 +- .../src/vespa/document/fieldvalue/fieldvalue.h | 2 +- .../document/fieldvalue/literalfieldvalue.cpp | 2 +- .../vespa/document/fieldvalue/literalfieldvalue.h | 8 ++--- .../vespa/document/fieldvalue/numericfieldvalue.h | 2 +- .../document/fieldvalue/numericfieldvalue.hpp | 2 +- .../vespa/document/fieldvalue/stringfieldvalue.cpp | 4 +-- .../vespa/document/fieldvalue/stringfieldvalue.h | 4 +-- .../vespa/document/fieldvalue/structfieldvalue.cpp | 4 +-- .../vespa/document/fieldvalue/structfieldvalue.h | 4 +-- .../document/fieldvalue/structuredfieldvalue.cpp | 12 +++---- .../document/fieldvalue/structuredfieldvalue.h | 14 ++++---- .../document/fieldvalue/structuredfieldvalue.hpp | 2 +- .../document/fieldvalue/weightedsetfieldvalue.h | 8 ++--- .../src/vespa/document/repo/documenttyperepo.cpp | 8 ++--- .../src/vespa/document/repo/documenttyperepo.h | 4 +-- document/src/vespa/document/select/branch.h | 2 +- document/src/vespa/document/select/doctype.cpp | 2 +- document/src/vespa/document/select/doctype.h | 2 +- .../src/vespa/document/select/invalidconstant.cpp | 2 +- .../src/vespa/document/select/invalidconstant.h | 2 +- document/src/vespa/document/select/node.h | 2 +- document/src/vespa/document/select/operator.cpp | 12 +++---- document/src/vespa/document/select/operator.h | 14 ++++---- .../src/vespa/document/select/simpleparser.cpp | 10 +++--- document/src/vespa/document/select/simpleparser.h | 14 ++++---- document/src/vespa/document/select/value.cpp | 2 +- document/src/vespa/document/select/value.h | 2 +- document/src/vespa/document/select/valuenodes.cpp | 6 ++-- document/src/vespa/document/select/valuenodes.h | 6 ++-- document/src/vespa/document/util/stringutil.cpp | 2 +- document/src/vespa/document/util/stringutil.h | 2 +- .../documentapi/messagebus/messages/visitor.h | 2 +- .../vespa/messagebus/routing/errordirective.cpp | 2 +- .../src/vespa/messagebus/routing/errordirective.h | 2 +- .../vespa/messagebus/routing/policydirective.cpp | 2 +- .../src/vespa/messagebus/routing/policydirective.h | 2 +- .../vespa/messagebus/routing/routedirective.cpp | 2 +- .../src/vespa/messagebus/routing/routedirective.h | 2 +- .../src/vespa/messagebus/routing/routeparser.cpp | 12 +++---- .../src/vespa/messagebus/routing/routeparser.h | 13 ++++--- .../src/vespa/messagebus/routing/tcpdirective.cpp | 2 +- .../src/vespa/messagebus/routing/tcpdirective.h | 2 +- .../vespa/messagebus/routing/verbatimdirective.cpp | 2 +- .../vespa/messagebus/routing/verbatimdirective.h | 2 +- metrics/src/vespa/metrics/metricmanager.cpp | 2 +- .../src/vespa/searchcommon/common/datatype.cpp | 4 +-- .../src/vespa/searchcommon/common/datatype.h | 4 +-- .../src/vespa/searchcommon/common/schema.cpp | 18 +++++----- .../src/vespa/searchcommon/common/schema.h | 26 +++++++------- .../vespa/searchcore/fdispatch/search/query.cpp | 2 +- .../src/vespa/searchcore/fdispatch/search/query.h | 4 +-- .../searchcore/fdispatch/search/search_path.cpp | 6 ++-- .../searchcore/fdispatch/search/search_path.h | 6 ++-- .../proton/matching/attribute_limiter.cpp | 2 +- .../searchcore/proton/matching/attribute_limiter.h | 2 +- .../src/vespa/searchcore/proton/matching/query.cpp | 2 +- .../src/vespa/searchcore/proton/matching/query.h | 2 +- .../searchcore/proton/matching/viewresolver.cpp | 4 +-- .../searchcore/proton/matching/viewresolver.h | 4 +-- .../vespa/searchcorespi/plugin/factoryloader.cpp | 10 +++--- .../src/vespa/searchcorespi/plugin/factoryloader.h | 2 +- .../vespa/searchcorespi/plugin/factoryregistry.cpp | 16 ++++----- .../vespa/searchcorespi/plugin/factoryregistry.h | 8 ++--- 86 files changed, 248 insertions(+), 259 deletions(-) diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp index 2433bfecdab..56c4e66cd1c 100644 --- a/document/src/tests/documentselectparsertest.cpp +++ b/document/src/tests/documentselectparsertest.cpp @@ -67,7 +67,7 @@ class DocumentSelectParserTest : public CppUnit::TestFixture { parseFieldValue(const std::string& expression); template - select::ResultList doParse(const vespalib::stringref& expr, + select::ResultList doParse(vespalib::stringref expr, const ContainsType& t); std::string parse_to_tree(const std::string& str); @@ -526,7 +526,7 @@ void DocumentSelectParserTest::testParseBranches() template select::ResultList -DocumentSelectParserTest::doParse(const vespalib::stringref& expr, +DocumentSelectParserTest::doParse(vespalib::stringref expr, const ContainsType& t) { std::unique_ptr root(_parser->parse(expr)); diff --git a/document/src/vespa/document/annotation/spantree.h b/document/src/vespa/document/annotation/spantree.h index e2839c4793b..4acd39b4793 100644 --- a/document/src/vespa/document/annotation/spantree.h +++ b/document/src/vespa/document/annotation/spantree.h @@ -21,7 +21,7 @@ public: typedef AnnotationVector::const_iterator const_iterator; template - SpanTree(const vespalib::stringref &name, std::unique_ptr root) + SpanTree(vespalib::stringref name, std::unique_ptr root) : _name(name), _root(std::move(root)) { assert(_root.get()); diff --git a/document/src/vespa/document/base/field.cpp b/document/src/vespa/document/base/field.cpp index 578294df7b0..c9173aa7457 100644 --- a/document/src/vespa/document/base/field.cpp +++ b/document/src/vespa/document/base/field.cpp @@ -11,7 +11,7 @@ namespace document { Field::Field() : Field("", 0, *DataType::INT, false) { } -Field::Field(const vespalib::stringref & name, int fieldId, +Field::Field(vespalib::stringref name, int fieldId, const DataType& dataType, bool headerField) : FieldBase(name), _dataType(&dataType), @@ -19,7 +19,7 @@ Field::Field(const vespalib::stringref & name, int fieldId, _isHeaderField(headerField) { } -Field::Field(const vespalib::stringref & name, +Field::Field(vespalib::stringref name, const DataType& dataType, bool headerField) : FieldBase(name), _dataType(&dataType), diff --git a/document/src/vespa/document/base/field.h b/document/src/vespa/document/base/field.h index cb16538c4f1..9f4bc09015f 100644 --- a/document/src/vespa/document/base/field.h +++ b/document/src/vespa/document/base/field.h @@ -48,7 +48,7 @@ public: * @param type The datatype of the field. * @param headerField Whether or not this is a "header" field. */ - Field(const vespalib::stringref & name, int fieldId, + Field(vespalib::stringref name, int fieldId, const DataType &type, bool headerField); Field(); @@ -61,7 +61,7 @@ public: * @param dataType The datatype of the field. * @param headerField Whether or not this is a "header" field. */ - Field(const vespalib::stringref & name, const DataType &dataType, bool headerField); + Field(vespalib::stringref name, const DataType &dataType, bool headerField); Field* clone() const override { return new Field(*this); } std::unique_ptr createValue() const; diff --git a/document/src/vespa/document/base/globalid.cpp b/document/src/vespa/document/base/globalid.cpp index 5211647e848..ca5235fac0b 100644 --- a/document/src/vespa/document/base/globalid.cpp +++ b/document/src/vespa/document/base/globalid.cpp @@ -85,7 +85,7 @@ vespalib::string GlobalId::toString() const { } GlobalId -GlobalId::parse(const vespalib::stringref & source) +GlobalId::parse(vespalib::stringref source) { if (source.substr(0, 6) != "gid(0x") { throw vespalib::IllegalArgumentException( diff --git a/document/src/vespa/document/base/globalid.h b/document/src/vespa/document/base/globalid.h index 6c8d0123a95..dd1d061dbf7 100644 --- a/document/src/vespa/document/base/globalid.h +++ b/document/src/vespa/document/base/globalid.h @@ -159,7 +159,7 @@ public: * @param str The string to parse. * @throws vespalib::IllegalArgumentException Thrown if input is not in GID format. */ - static GlobalId parse(const vespalib::stringref &str); + static GlobalId parse(vespalib::stringref str); /** * Returns the most specified bucket id to which this global id belongs. diff --git a/document/src/vespa/document/base/idstring.cpp b/document/src/vespa/document/base/idstring.cpp index 175fb653542..eee8d3c38a2 100644 --- a/document/src/vespa/document/base/idstring.cpp +++ b/document/src/vespa/document/base/idstring.cpp @@ -49,8 +49,8 @@ IdString::toString() const namespace { void reportError(const char* part) __attribute__((noinline)); -void reportError(const stringref & s) __attribute__((noinline)); -void reportError(const stringref & s, const char* part) __attribute__((noinline)); +void reportError(stringref s) __attribute__((noinline)); +void reportError(stringref s, const char* part) __attribute__((noinline)); void reportTooShortDocId(const char * id, size_t sz) __attribute__((noinline)); void reportNoSchemeSeparator(const char * id) __attribute__((noinline)); @@ -58,13 +58,12 @@ void reportError(const char* part) { throw IdParseException(make_string("Unparseable id: No %s separator ':' found", part), VESPA_STRLOC); } -void reportError(const stringref & s, const char* part) +void reportError(stringref s, const char* part) { - throw IdParseException(make_string("Unparseable %s '%s': Not an unsigned 64-bit number", part, - string(s).c_str()), VESPA_STRLOC); + throw IdParseException(make_string("Unparseable %s '%s': Not an unsigned 64-bit number", part, string(s).c_str()), VESPA_STRLOC); } -void reportError(const stringref & s) +void reportError(stringref s) { throw IdParseException(make_string("Unparseable order doc scheme '%s': Scheme must contain parameters on the form (width, division)", string(s).c_str()), VESPA_STRLOC); @@ -76,13 +75,10 @@ void reportNoSchemeSeparator(const char * id) void reportTooShortDocId(const char * id, size_t sz) { - throw IdParseException( - make_string( - "Unparseable id '%s': It is too short(%li) " - "to make any sense", id, sz), VESPA_STRLOC); + throw IdParseException( make_string( "Unparseable id '%s': It is too short(%li) " "to make any sense", id, sz), VESPA_STRLOC); } -uint64_t getAsNumber(const stringref & s, const char* part) { +uint64_t getAsNumber(stringref s, const char* part) { char* errPos = NULL; uint64_t value = strtoull(s.data(), &errPos, 10); @@ -93,7 +89,7 @@ uint64_t getAsNumber(const stringref & s, const char* part) { } void -getOrderDocBits(const stringref& scheme, uint16_t & widthBits, uint16_t & divisionBits) +getOrderDocBits(stringref scheme, uint16_t & widthBits, uint16_t & divisionBits) { const char* parenPos = reinterpret_cast( memchr(scheme.data(), '(', scheme.size())); @@ -194,7 +190,7 @@ fmemchr(const char * s, const char * e) } // namespace -IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, const stringref & id) +IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, stringref id) { _offsets[0] = namespaceOffset; size_t index(1); @@ -213,7 +209,7 @@ IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, con _offsets[maxComponents] = id.size() + 1; // 1 is added due to the implicitt accounting for ':' } -IdString::IdString(uint32_t maxComponents, uint32_t namespaceOffset, const stringref & rawId) : +IdString::IdString(uint32_t maxComponents, uint32_t namespaceOffset, stringref rawId) : _offsets(maxComponents, namespaceOffset, rawId), _rawId(rawId) { @@ -274,13 +270,13 @@ union LocationUnion { IdString::LocationType _location[2]; }; -IdString::LocationType makeLocation(const stringref &s) { +IdString::LocationType makeLocation(stringref s) { LocationUnion location; fastc_md5sum(reinterpret_cast(s.data()), s.size(), location._key); return location._location[0]; } -uint64_t parseNumber(const stringref &number) { +uint64_t parseNumber(stringref number) { char* errPos = NULL; errno = 0; uint64_t n = strtoul(number.data(), &errPos, 10); @@ -297,7 +293,7 @@ uint64_t parseNumber(const stringref &number) { } void setLocation(IdString::LocationType &loc, IdString::LocationType val, - bool &has_set_location, const stringref &key_values) { + bool &has_set_location, stringref key_values) { if (has_set_location) { throw IdParseException("Illegal key combination in " + key_values); @@ -309,7 +305,7 @@ void setLocation(IdString::LocationType &loc, IdString::LocationType val, } // namespace -IdIdString::IdIdString(const stringref & id) +IdIdString::IdIdString(stringref id) : IdString(4, 3, id), _location(0), _groupOffset(0), @@ -364,26 +360,26 @@ GroupDocIdString::getLocation() const return makeLocation(getGroup()); } -DocIdString::DocIdString(const stringref & ns, const stringref & id) : +DocIdString::DocIdString(stringref ns, stringref id) : IdString(2, 4, "doc:" + ns + ":" + id) { validate(); } -DocIdString::DocIdString(const stringref & rawId) : +DocIdString::DocIdString(stringref rawId) : IdString(2, 4, rawId) { validate(); } -UserDocIdString::UserDocIdString(const stringref & rawId) : +UserDocIdString::UserDocIdString(stringref rawId) : IdString(3, 8, rawId), _userId(getAsNumber(rawId.substr(offset(1), offset(2) - offset(1) - 1), "userid")) { validate(); } -GroupDocIdString::GroupDocIdString(const stringref & rawId) : +GroupDocIdString::GroupDocIdString(stringref rawId) : IdString(3, 9, rawId) { validate(); @@ -395,7 +391,7 @@ GroupDocIdString::locationFromGroupName(vespalib::stringref name) return makeLocation(name); } -OrderDocIdString::OrderDocIdString(const stringref & rawId) : +OrderDocIdString::OrderDocIdString(stringref rawId) : IdString(4, static_cast(memchr(rawId.data(), ':', rawId.size())) - rawId.data() + 1, rawId), _widthBits(0), _divisionBits(0), diff --git a/document/src/vespa/document/base/idstring.h b/document/src/vespa/document/base/idstring.h index b1a14cfec94..27e49c6f6ff 100644 --- a/document/src/vespa/document/base/idstring.h +++ b/document/src/vespa/document/base/idstring.h @@ -24,7 +24,7 @@ public: static const vespalib::string & getTypeName(Type t); /** @throws document::IdParseException If parsing of id scheme failed. */ - static IdString::UP createIdString(const vespalib::stringref & id) { return createIdString(id.data(), id.size()); } + static IdString::UP createIdString(vespalib::stringref id) { return createIdString(id.data(), id.size()); } static IdString::UP createIdString(const char *id, size_t sz); ~IdString() {} @@ -48,7 +48,7 @@ public: const vespalib::string & toString() const; protected: - IdString(uint32_t maxComponents, uint32_t namespaceOffset, const vespalib::stringref & rawId); + IdString(uint32_t maxComponents, uint32_t namespaceOffset, vespalib::stringref rawId); virtual vespalib::string getSchemeName() const; size_t offset(size_t index) const { return _offsets[index]; } size_t size(size_t index) const { return _offsets[index+1] - _offsets[index] - 1; } @@ -60,7 +60,7 @@ protected: private: class Offsets { public: - Offsets(uint32_t maxComponents, uint32_t first, const vespalib::stringref & id); + Offsets(uint32_t maxComponents, uint32_t first, vespalib::stringref id); uint16_t first() const { return _offsets[0]; } uint16_t operator [] (size_t i) const { return _offsets[i]; } size_t numComponents() const { return _numComponents; } @@ -100,7 +100,7 @@ class IdIdString final : public IdString { bool _has_number; public: - IdIdString(const vespalib::stringref &ns); + IdIdString(vespalib::stringref ns); bool hasDocType() const override { return true; } vespalib::stringref getDocType() const override { return getComponent(1); } @@ -129,8 +129,8 @@ private: */ class DocIdString final : public IdString { public: - DocIdString(const vespalib::stringref & ns, const vespalib::stringref & id); - DocIdString(const vespalib::stringref & rawId); + DocIdString(vespalib::stringref ns, vespalib::stringref id); + DocIdString(vespalib::stringref rawId); private: DocIdString* clone() const override { return new DocIdString(*this); } Type getType() const override { return DOC; } @@ -150,7 +150,7 @@ private: */ class UserDocIdString final : public IdString { public: - UserDocIdString(const vespalib::stringref & rawId); + UserDocIdString(vespalib::stringref rawId); virtual int64_t getUserId() const { return _userId; } bool hasNumber() const override { return true; } @@ -172,7 +172,7 @@ private: */ class OrderDocIdString final : public IdString { public: - OrderDocIdString(const vespalib::stringref& rawId); + OrderDocIdString(vespalib::stringref rawId); int64_t getUserId() const { return _location; } uint16_t getWidthBits() const { return _widthBits; } @@ -207,7 +207,7 @@ private: */ class GroupDocIdString : public IdString { public: - GroupDocIdString(const vespalib::stringref & rawId); + GroupDocIdString(vespalib::stringref rawId); bool hasGroup() const override { return true; } vespalib::stringref getGroup() const override { return getComponent(1); } LocationType getLocation() const override; diff --git a/document/src/vespa/document/datatype/collectiondatatype.cpp b/document/src/vespa/document/datatype/collectiondatatype.cpp index f09aebb0be5..4642ce31b13 100644 --- a/document/src/vespa/document/datatype/collectiondatatype.cpp +++ b/document/src/vespa/document/datatype/collectiondatatype.cpp @@ -24,13 +24,13 @@ CollectionDataType::operator=(const CollectionDataType& other) return *this; } -CollectionDataType::CollectionDataType(const vespalib::stringref& name, +CollectionDataType::CollectionDataType(vespalib::stringref name, const DataType& nestedType) : DataType(name), _nestedType(&nestedType) { } -CollectionDataType::CollectionDataType(const vespalib::stringref& name, +CollectionDataType::CollectionDataType(vespalib::stringref name, const DataType& nestedType, int32_t id) : DataType(name, id), diff --git a/document/src/vespa/document/datatype/collectiondatatype.h b/document/src/vespa/document/datatype/collectiondatatype.h index 0e258e3e0cf..3f59a09e876 100644 --- a/document/src/vespa/document/datatype/collectiondatatype.h +++ b/document/src/vespa/document/datatype/collectiondatatype.h @@ -20,9 +20,9 @@ protected: CollectionDataType() : _nestedType(0) {} CollectionDataType(const CollectionDataType&); CollectionDataType& operator=(const CollectionDataType&); - CollectionDataType(const vespalib::stringref & name, + CollectionDataType(vespalib::stringref name, const DataType &nestedType); - CollectionDataType(const vespalib::stringref & name, + CollectionDataType(vespalib::stringref name, const DataType &nestedType, int32_t id); public: diff --git a/document/src/vespa/document/datatype/datatype.cpp b/document/src/vespa/document/datatype/datatype.cpp index 3b56942b61e..18dd4b7a7a4 100644 --- a/document/src/vespa/document/datatype/datatype.cpp +++ b/document/src/vespa/document/datatype/datatype.cpp @@ -118,7 +118,7 @@ namespace { // ASCII characters. Probably screwed up otherwise, but generated ids // should only be used in testing anyways. In production this will be // set from the document manager config. -uint32_t crappyJavaStringHash(const vespalib::stringref & value) { +uint32_t crappyJavaStringHash(vespalib::stringref value) { uint32_t h = 0; for (uint32_t i = 0; i < value.size(); ++i) { h = 31 * h + value[i]; @@ -126,7 +126,7 @@ uint32_t crappyJavaStringHash(const vespalib::stringref & value) { return h; } -int32_t createId(const vespalib::stringref & name) +int32_t createId(vespalib::stringref name) { if (name == "Tag") { return DataType::T_TAG; @@ -142,13 +142,13 @@ DataType::DataType() { } -DataType::DataType(const vespalib::stringref & name, int dataTypeId) +DataType::DataType(vespalib::stringref name, int dataTypeId) : _dataTypeId(dataTypeId), _name(name) { } -DataType::DataType(const vespalib::stringref & name) +DataType::DataType(vespalib::stringref name) : _dataTypeId(createId(name)), _name(name) { diff --git a/document/src/vespa/document/datatype/datatype.h b/document/src/vespa/document/datatype/datatype.h index 5857157c218..edb23d59e8b 100644 --- a/document/src/vespa/document/datatype/datatype.h +++ b/document/src/vespa/document/datatype/datatype.h @@ -38,12 +38,12 @@ protected: * everyone to be able to use them. Only tests and the type manager reading * config should need to create datatypes. */ - DataType(const vespalib::stringref& name, int dataTypeId); + DataType(vespalib::stringref name, int dataTypeId); /** * Creates a datatype using the hash of name as the id. */ - explicit DataType(const vespalib::stringref& name); + explicit DataType(vespalib::stringref name); public: virtual ~DataType(); diff --git a/document/src/vespa/document/datatype/documenttype.cpp b/document/src/vespa/document/datatype/documenttype.cpp index 2be5acaf3db..8198abfc7b1 100644 --- a/document/src/vespa/document/datatype/documenttype.cpp +++ b/document/src/vespa/document/datatype/documenttype.cpp @@ -22,7 +22,7 @@ DocumentType::DocumentType() { } -DocumentType::DocumentType(const stringref& name, int32_t id) +DocumentType::DocumentType(stringref name, int32_t id) : StructuredDataType(name, id), _inheritedTypes(), _ownedFields(new StructDataType(name + ".header")), @@ -34,7 +34,7 @@ DocumentType::DocumentType(const stringref& name, int32_t id) } } -DocumentType::DocumentType(const stringref& name, int32_t id, const StructDataType& fields) +DocumentType::DocumentType(stringref name, int32_t id, const StructDataType& fields) : StructuredDataType(name, id), _inheritedTypes(), _fields(&fields), @@ -45,7 +45,7 @@ DocumentType::DocumentType(const stringref& name, int32_t id, const StructDataTy } } -DocumentType::DocumentType(const stringref& name) +DocumentType::DocumentType(stringref name) : StructuredDataType(name), _inheritedTypes(), _ownedFields(new StructDataType(name + ".header")), @@ -57,7 +57,7 @@ DocumentType::DocumentType(const stringref& name) } } -DocumentType::DocumentType(const stringref& name, const StructDataType& fields) +DocumentType::DocumentType(stringref name, const StructDataType& fields) : StructuredDataType(name), _inheritedTypes(), _fields(&fields), @@ -210,7 +210,7 @@ DocumentType::operator==(const DataType& other) const } const Field& -DocumentType::getField(const stringref& name) const +DocumentType::getField(stringref name) const { return _fields->getField(name); } @@ -221,7 +221,7 @@ DocumentType::getField(int fieldId) const return _fields->getField(fieldId); } -bool DocumentType::hasField(const stringref &name) const { +bool DocumentType::hasField(stringref name) const { return _fields->hasField(name); } diff --git a/document/src/vespa/document/datatype/documenttype.h b/document/src/vespa/document/datatype/documenttype.h index 89034a86810..78abd3077e6 100644 --- a/document/src/vespa/document/datatype/documenttype.h +++ b/document/src/vespa/document/datatype/documenttype.h @@ -50,12 +50,12 @@ public: typedef std::shared_ptr SP; DocumentType(); - DocumentType(const vespalib::stringref &name, int32_t id); - DocumentType(const vespalib::stringref &name, int32_t id, + DocumentType(vespalib::stringref name, int32_t id); + DocumentType(vespalib::stringref name, int32_t id, const StructDataType& fields); - DocumentType(const vespalib::stringref &name); - DocumentType(const vespalib::stringref &name, + DocumentType(vespalib::stringref name); + DocumentType(vespalib::stringref name, const StructDataType& fields); ~DocumentType(); @@ -82,9 +82,9 @@ public: uint32_t getFieldCount() const override { return _fields->getFieldCount(); } - const Field & getField(const vespalib::stringref & name) const override; + const Field & getField(vespalib::stringref name) const override; const Field & getField(int fieldId) const override; - bool hasField(const vespalib::stringref &name) const override; + bool hasField(vespalib::stringref name) const override; bool hasField(int fieldId) const override; Field::Set getFieldSet() const override; DocumentType* clone() const override; diff --git a/document/src/vespa/document/datatype/structdatatype.cpp b/document/src/vespa/document/datatype/structdatatype.cpp index 9ff0b7e0b0a..35cd02dab88 100644 --- a/document/src/vespa/document/datatype/structdatatype.cpp +++ b/document/src/vespa/document/datatype/structdatatype.cpp @@ -26,14 +26,14 @@ StructDataType::StructDataType() : _compressionConfig() { } -StructDataType::StructDataType(const vespalib::stringref &name) +StructDataType::StructDataType(vespalib::stringref name) : StructuredDataType(name), _nameFieldMap(), _idFieldMap(), _compressionConfig() { } -StructDataType::StructDataType(const vespalib::stringref & name, int32_t dataTypeId) +StructDataType::StructDataType(vespalib::stringref name, int32_t dataTypeId) : StructuredDataType(name, dataTypeId), _nameFieldMap(), _idFieldMap(), @@ -122,7 +122,7 @@ StructDataType::createFieldValue() const } const Field& -StructDataType::getField(const vespalib::stringref & name) const +StructDataType::getField(vespalib::stringref name) const { StringFieldMap::const_iterator it(_nameFieldMap.find(name)); if (it == _nameFieldMap.end()) { @@ -153,7 +153,7 @@ StructDataType::getField(int32_t fieldId) const return *it->second; } -bool StructDataType::hasField(const vespalib::stringref &name) const { +bool StructDataType::hasField(vespalib::stringref name) const { return _nameFieldMap.find(name) != _nameFieldMap.end(); } diff --git a/document/src/vespa/document/datatype/structdatatype.h b/document/src/vespa/document/datatype/structdatatype.h index 0f1c58316c9..5dc39639831 100644 --- a/document/src/vespa/document/datatype/structdatatype.h +++ b/document/src/vespa/document/datatype/structdatatype.h @@ -23,8 +23,8 @@ public: using CompressionConfig = vespalib::compression::CompressionConfig; StructDataType(); - StructDataType(const vespalib::stringref &name); - StructDataType(const vespalib::stringref &name, int32_t id); + StructDataType(vespalib::stringref name); + StructDataType(vespalib::stringref name, int32_t id); ~StructDataType(); /** @@ -48,7 +48,7 @@ public: void print(std::ostream&, bool verbose, const std::string& indent) const override; uint32_t getFieldCount() const override { return _idFieldMap.size(); } - const Field& getField(const vespalib::stringref & name) const override; + const Field& getField(vespalib::stringref name) const override; /** * Retrieves a field based on its ID. To determine which ID to use, we also @@ -56,7 +56,7 @@ public: */ const Field& getField(int32_t fieldId) const override; - bool hasField(const vespalib::stringref &name) const override; + bool hasField(vespalib::stringref name) const override; bool hasField(int32_t fieldId) const override; bool hasField(const Field& f) const { return hasField(f.getId()); diff --git a/document/src/vespa/document/datatype/structureddatatype.cpp b/document/src/vespa/document/datatype/structureddatatype.cpp index 604b4cad045..bdd56b94d51 100644 --- a/document/src/vespa/document/datatype/structureddatatype.cpp +++ b/document/src/vespa/document/datatype/structureddatatype.cpp @@ -13,12 +13,12 @@ IMPLEMENT_IDENTIFIABLE_ABSTRACT(StructuredDataType, DataType); StructuredDataType::StructuredDataType() = default; -StructuredDataType::StructuredDataType(const vespalib::stringref &name) +StructuredDataType::StructuredDataType(vespalib::stringref name) : DataType(name, createId(name)) { } -StructuredDataType::StructuredDataType(const vespalib::stringref &name, int dataTypeId) +StructuredDataType::StructuredDataType(vespalib::stringref name, int dataTypeId) : DataType(name, dataTypeId) { } @@ -30,7 +30,7 @@ bool StructuredDataType::operator==(const DataType& type) const } namespace { -uint32_t crappyJavaStringHash(const vespalib::stringref &value) { +uint32_t crappyJavaStringHash(vespalib::stringref value) { uint32_t h = 0; for (uint32_t i = 0; i < value.size(); ++i) { h = 31 * h + value[i]; @@ -39,7 +39,7 @@ uint32_t crappyJavaStringHash(const vespalib::stringref &value) { } } // namespace -int32_t StructuredDataType::createId(const vespalib::stringref &name) +int32_t StructuredDataType::createId(vespalib::stringref name) { if (name == "document") { return 8; diff --git a/document/src/vespa/document/datatype/structureddatatype.h b/document/src/vespa/document/datatype/structureddatatype.h index 31de0d93680..c3c49765235 100644 --- a/document/src/vespa/document/datatype/structureddatatype.h +++ b/document/src/vespa/document/datatype/structureddatatype.h @@ -20,17 +20,17 @@ class StructuredDataType : public DataType { protected: StructuredDataType(); - StructuredDataType(const vespalib::stringref & name); - StructuredDataType(const vespalib::stringref & name, int32_t dataTypeId); + StructuredDataType(vespalib::stringref name); + StructuredDataType(vespalib::stringref name, int32_t dataTypeId); public: virtual uint32_t getFieldCount() const = 0; /** @throws FieldNotFoundException if field does not exist. */ - virtual const Field& getField(const vespalib::stringref & name) const = 0; + virtual const Field& getField(vespalib::stringref name) const = 0; - virtual bool hasField(const vespalib::stringref & name) const = 0; + virtual bool hasField(vespalib::stringref name) const = 0; virtual bool hasField(int32_t fieldId) const = 0; virtual Field::Set getFieldSet() const = 0; @@ -38,7 +38,7 @@ public: virtual StructuredDataType* clone() const override = 0; bool operator==(const DataType& type) const override; - static int32_t createId(const vespalib::stringref &name); + static int32_t createId(vespalib::stringref name); DECLARE_IDENTIFIABLE_ABSTRACT(StructuredDataType); diff --git a/document/src/vespa/document/fieldset/fieldsetrepo.cpp b/document/src/vespa/document/fieldset/fieldsetrepo.cpp index e1e2ed35ca6..93cb20445c6 100644 --- a/document/src/vespa/document/fieldset/fieldsetrepo.cpp +++ b/document/src/vespa/document/fieldset/fieldsetrepo.cpp @@ -13,7 +13,7 @@ namespace document { namespace { FieldSet::UP -parseSpecialValues(const vespalib::stringref & name) +parseSpecialValues(vespalib::stringref name) { FieldSet::UP fs; if ((name.size() == 4) && (name[1] == 'i') && (name[2] == 'd') && (name[3] == ']')) { diff --git a/document/src/vespa/document/fieldvalue/collectionfieldvalue.h b/document/src/vespa/document/fieldvalue/collectionfieldvalue.h index a94fe89e549..bc4950793a4 100644 --- a/document/src/vespa/document/fieldvalue/collectionfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/collectionfieldvalue.h @@ -64,7 +64,7 @@ public: // Convenience functions for using primitives directly - bool add(const vespalib::stringref & val) + bool add(vespalib::stringref val) { return addValue(*createNested() = val); } bool add(int32_t val) { return addValue(*createNested() = val); } @@ -75,7 +75,7 @@ public: bool add(double val) { return addValue(*createNested() = val); } - bool contains(const vespalib::stringref & val) + bool contains(vespalib::stringref val) { return containsValue(*createNested() = val); } bool contains(int32_t val) { return containsValue(*createNested() = val); } @@ -86,7 +86,7 @@ public: bool contains(double val) { return containsValue(*createNested() = val); } - bool remove(const vespalib::stringref & val) + bool remove(vespalib::stringref val) { return removeValue(*createNested() = val); } bool remove(int32_t val) { return removeValue(*createNested() = val); } diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp index 51ba135b826..b2cae1613de 100644 --- a/document/src/vespa/document/fieldvalue/document.cpp +++ b/document/src/vespa/document/fieldvalue/document.cpp @@ -28,10 +28,10 @@ bool isLegalVersion(uint16_t version) { return (6 <= version) && (version <= 8); } -void documentTypeError(const vespalib::stringref & name) __attribute__((noinline)); +void documentTypeError(vespalib::stringref name) __attribute__((noinline)); void throwTypeMismatch(vespalib::stringref type, vespalib::stringref docidType) __attribute__((noinline)); -void documentTypeError(const vespalib::stringref & name) { +void documentTypeError(vespalib::stringref name) { throw IllegalArgumentException(make_string("Cannot generate a document with non-document type %s.", vespalib::string(name).c_str()), VESPA_STRLOC); } diff --git a/document/src/vespa/document/fieldvalue/document.h b/document/src/vespa/document/fieldvalue/document.h index e0a35411f9b..b5e2643ce80 100644 --- a/document/src/vespa/document/fieldvalue/document.h +++ b/document/src/vespa/document/fieldvalue/document.h @@ -79,8 +79,8 @@ public: const StructFieldValue& getFields() const { return _fields; } StructFieldValue& getFields() { return _fields; } - const Field& getField(const vespalib::stringref & name) const override { return _fields.getField(name); } - bool hasField(const vespalib::stringref & name) const override { return _fields.hasField(name); } + const Field& getField(vespalib::stringref name) const override { return _fields.getField(name); } + bool hasField(vespalib::stringref name) const override { return _fields.hasField(name); } void clear() override; diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.cpp b/document/src/vespa/document/fieldvalue/fieldvalue.cpp index 44de51e7fe1..f5cd92ddc06 100644 --- a/document/src/vespa/document/fieldvalue/fieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/fieldvalue.cpp @@ -106,7 +106,7 @@ FieldValue::toXml(const std::string& indent) const // Subtypes should implement the conversion functions that make sense -FieldValue& FieldValue::operator=(const vespalib::stringref &) +FieldValue& FieldValue::operator=(vespalib::stringref ) { throw vespalib::IllegalArgumentException( "Cannot assign string to datatype " + getDataType()->toString(), diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.h b/document/src/vespa/document/fieldvalue/fieldvalue.h index 0f7e1fb432c..8fe47d64981 100644 --- a/document/src/vespa/document/fieldvalue/fieldvalue.h +++ b/document/src/vespa/document/fieldvalue/fieldvalue.h @@ -113,7 +113,7 @@ public: virtual std::string toXml(const std::string& indent = "") const; // Utility functions to set commonly used value types. - virtual FieldValue& operator=(const vespalib::stringref &); + virtual FieldValue& operator=(vespalib::stringref ); virtual FieldValue& operator=(int32_t); virtual FieldValue& operator=(int64_t); virtual FieldValue& operator=(float); diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp index 5614330a495..0ae1e5fa0dd 100644 --- a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp @@ -91,7 +91,7 @@ print(std::ostream& out, bool, const std::string&) const } FieldValue& -LiteralFieldValueB::operator=(const vespalib::stringref & value) +LiteralFieldValueB::operator=(vespalib::stringref value) { setValue(value); return *this; diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.h b/document/src/vespa/document/fieldvalue/literalfieldvalue.h index 2f9050eb13c..a37b612acbb 100644 --- a/document/src/vespa/document/fieldvalue/literalfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.h @@ -14,8 +14,8 @@ */ #pragma once +#include "fieldvalue.h" #include -#include #include namespace document { @@ -44,12 +44,12 @@ public: LiteralFieldValueB & operator=(const LiteralFieldValueB &); - void setValueRef(const stringref & value) { + void setValueRef(stringref value) { _value = value; _altered = true; } - void setValue(const stringref & value) { + void setValue(stringref value) { _backing = value; _value = _backing; _altered = true; @@ -68,7 +68,7 @@ public: FieldValue& assign(const FieldValue&) override; bool hasChanged() const override{ return _altered; } - FieldValue& operator=(const vespalib::stringref &) override; + FieldValue& operator=(vespalib::stringref ) override; FieldValue& operator=(int32_t) override; FieldValue& operator=(int64_t) override; FieldValue& operator=(float) override; diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.h b/document/src/vespa/document/fieldvalue/numericfieldvalue.h index 2f44153c09c..5e6689e35cd 100644 --- a/document/src/vespa/document/fieldvalue/numericfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.h @@ -40,7 +40,7 @@ public: int compare(const FieldValue& other) const override; int fastCompare(const FieldValue& other) const override final; - FieldValue& operator=(const vespalib::stringref &) override; + FieldValue& operator=(vespalib::stringref ) override; FieldValue& operator=(int32_t) override; FieldValue& operator=(int64_t) override; FieldValue& operator=(float) override; diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp index c3ef6781706..cba0e587a94 100644 --- a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp +++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp @@ -78,7 +78,7 @@ NumericFieldValue::print(std::ostream& out, bool, const std::string&) co template FieldValue& -NumericFieldValue::operator=(const vespalib::stringref & value) +NumericFieldValue::operator=(vespalib::stringref value) { // Lexical cast doesn't allow hex syntax we use in XML, // so detect these in front. diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp b/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp index 5ee0acfb6f9..13db6ecbf46 100644 --- a/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp @@ -87,7 +87,7 @@ StringFieldValue::doClearSpanTrees() { _annotationData.reset(); } -const SpanTree * StringFieldValue::findTree(const SpanTrees & trees, const stringref & name) +const SpanTree * StringFieldValue::findTree(const SpanTrees & trees, stringref name) { for(const auto & tree : trees) { if (tree->getName() == name) { @@ -97,7 +97,7 @@ const SpanTree * StringFieldValue::findTree(const SpanTrees & trees, const strin return nullptr; } -StringFieldValue &StringFieldValue::operator=(const stringref& value) +StringFieldValue &StringFieldValue::operator=(stringref value) { setValue(value); _annotationData.reset(); diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.h b/document/src/vespa/document/fieldvalue/stringfieldvalue.h index 14b67838787..015fcd5ba22 100644 --- a/document/src/vespa/document/fieldvalue/stringfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.h @@ -30,7 +30,7 @@ public: StringFieldValue(const StringFieldValue &rhs); StringFieldValue &operator=(const StringFieldValue &rhs); - StringFieldValue &operator=(const vespalib::stringref &value) override; + StringFieldValue &operator=(vespalib::stringref value) override; ~StringFieldValue(); FieldValue &assign(const FieldValue &) override; @@ -48,7 +48,7 @@ public: return _annotationData ? _annotationData->getSerializedAnnotations() : vespalib::ConstBufferRef(); } bool hasSpanTrees() const { return _annotationData ? _annotationData->hasSpanTrees() : false; } - static const SpanTree *findTree(const SpanTrees &trees, const vespalib::stringref &name); + static const SpanTree *findTree(const SpanTrees &trees, vespalib::stringref name); void clearSpanTrees() { if (_annotationData) { doClearSpanTrees(); diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp index 7f88229e1ba..febd0dc355c 100644 --- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp @@ -159,13 +159,13 @@ StructFieldValue::getRawFieldIds(vector &raw_ids, } bool -StructFieldValue::hasField(const vespalib::stringref & name) const +StructFieldValue::hasField(vespalib::stringref name) const { return getStructType().hasField(name); } const Field& -StructFieldValue::getField(const vespalib::stringref & name) const +StructFieldValue::getField(vespalib::stringref name) const { return getStructType().getField(name); } diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.h b/document/src/vespa/document/fieldvalue/structfieldvalue.h index bb6956cf012..3f21feafcbb 100644 --- a/document/src/vespa/document/fieldvalue/structfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/structfieldvalue.h @@ -83,8 +83,8 @@ public: void accept(FieldValueVisitor &visitor) override { visitor.visit(*this); } void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); } - bool hasField(const vespalib::stringref & name) const override; - const Field& getField(const vespalib::stringref & name) const override; + bool hasField(vespalib::stringref name) const override; + const Field& getField(vespalib::stringref name) const override; void clear() override; const CompressionConfig &getCompressionConfig() const; diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp index c193b0919ea..8ed13104dd6 100644 --- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp @@ -244,12 +244,12 @@ StructuredFieldValue::commitTransaction() { } using ConstCharP = const char *; -template void StructuredFieldValue::set(const vespalib::stringref & field, int32_t value); -template void StructuredFieldValue::set(const vespalib::stringref & field, int64_t value); -template void StructuredFieldValue::set(const vespalib::stringref & field, double value); -template void StructuredFieldValue::set(const vespalib::stringref & field, ConstCharP value); -template void StructuredFieldValue::set(const vespalib::stringref & field, vespalib::stringref value); -template void StructuredFieldValue::set(const vespalib::stringref & field, vespalib::string value); +template void StructuredFieldValue::set(vespalib::stringref field, int32_t value); +template void StructuredFieldValue::set(vespalib::stringref field, int64_t value); +template void StructuredFieldValue::set(vespalib::stringref field, double value); +template void StructuredFieldValue::set(vespalib::stringref field, ConstCharP value); +template void StructuredFieldValue::set(vespalib::stringref field, vespalib::stringref value); +template void StructuredFieldValue::set(vespalib::stringref field, vespalib::string value); template std::unique_ptr StructuredFieldValue::getAs(const Field &field) const; template std::unique_ptr StructuredFieldValue::getAs(const Field &field) const; diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.h b/document/src/vespa/document/fieldvalue/structuredfieldvalue.h index d93bee9b093..b415596b292 100644 --- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.h @@ -112,12 +112,12 @@ public: const DataType *getDataType() const override { return _type; } /** Wrapper for DataType's hasField() function. */ - virtual bool hasField(const vespalib::stringref & name) const = 0; + virtual bool hasField(vespalib::stringref name) const = 0; /** * Wrapper for DataType's getField() function. * @throws FieldNotFoundException If no field with given name exist. */ - virtual const Field& getField(const vespalib::stringref & name) const = 0; + virtual const Field& getField(vespalib::stringref name) const = 0; void beginTransaction(); void commitTransaction(); @@ -136,7 +136,7 @@ public: return getFieldValue(field); } /** @return Retrieve value of given field. Null pointer if not set. */ - FieldValue::UP getValue(const vespalib::stringref & name) const { + FieldValue::UP getValue(vespalib::stringref name) const { return getFieldValue(getField(name)); } /** @return True if value is set. */ @@ -159,16 +159,16 @@ public: virtual void clear() = 0; // Utility functions for easy but less efficient access - bool hasValue(const vespalib::stringref & fieldName) const + bool hasValue(vespalib::stringref fieldName) const { return hasFieldValue(getField(fieldName)); } - void remove(const vespalib::stringref & fieldName) + void remove(vespalib::stringref fieldName) { removeFieldValue(getField(fieldName)); } - void setValue(const vespalib::stringref & fieldName, const FieldValue& value) + void setValue(vespalib::stringref fieldName, const FieldValue& value) { setFieldValue(getField(fieldName), value); } template void set(const Field& field, PrimitiveType value); template - void set(const vespalib::stringref & fieldName, PrimitiveType value); + void set(vespalib::stringref fieldName, PrimitiveType value); size_t getSetFieldCount() const { size_t count = 0; diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp index 3e23619be60..8d20cce9e66 100644 --- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp +++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp @@ -31,7 +31,7 @@ StructuredFieldValue::set(const Field& field, PrimitiveType value) template void -StructuredFieldValue::set(const vespalib::stringref & fieldName, PrimitiveType value) +StructuredFieldValue::set(vespalib::stringref fieldName, PrimitiveType value) { set(getField(fieldName), value); } diff --git a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h index 0f73e2602d3..fafe8f15e0e 100644 --- a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h @@ -97,7 +97,7 @@ public: // Utility functions for easy use of weighted sets of primitives - bool add(const vespalib::stringref & val, int32_t weight = 1) + bool add(vespalib::stringref val, int32_t weight = 1) { return add(*createNested() = val, weight); } bool add(int32_t val, int32_t weight = 1) { return add(*createNested() = val, weight); } @@ -108,7 +108,7 @@ public: bool add(double val, int32_t weight = 1) { return add(*createNested() = val, weight); } - int32_t get(const vespalib::stringref & val) const + int32_t get(vespalib::stringref val) const { return get(*createNested() = val); } int32_t get(int32_t val) const { return get(*createNested() = val); } @@ -119,7 +119,7 @@ public: int32_t get(double val) const { return get(*createNested() = val); } - void increment(const vespalib::stringref & val, int32_t weight = 1) + void increment(vespalib::stringref val, int32_t weight = 1) { increment(*createNested() = val, weight); } void increment(int32_t val, int32_t weight = 1) { increment(*createNested() = val, weight); } @@ -130,7 +130,7 @@ public: void increment(double val, int32_t weight = 1) { increment(*createNested() = val, weight); } - void decrement(const vespalib::stringref & val, int32_t weight = 1) + void decrement(vespalib::stringref val, int32_t weight = 1) { decrement(*createNested() = val, weight); } void decrement(int32_t val, int32_t weight = 1) { decrement(*createNested() = val, weight); } diff --git a/document/src/vespa/document/repo/documenttyperepo.cpp b/document/src/vespa/document/repo/documenttyperepo.cpp index a2f5aeb8f0b..03b7660efbe 100644 --- a/document/src/vespa/document/repo/documenttyperepo.cpp +++ b/document/src/vespa/document/repo/documenttyperepo.cpp @@ -76,7 +76,7 @@ public: template void addDataType(unique_ptr type); const DataType *lookup(int32_t id) const; - const DataType *lookup(const stringref &name) const; + const DataType *lookup(stringref name) const; const DataType &findOrThrow(int32_t id) const; }; @@ -127,7 +127,7 @@ const DataType *Repo::lookup(int32_t id) const { return FindPtr(_types, id); } -const DataType *Repo::lookup(const stringref &n) const { +const DataType *Repo::lookup(stringref n) const { return FindPtr(_name_map, n); } @@ -523,7 +523,7 @@ DocumentTypeRepo::getDocumentType(int32_t type_id) const { } const DocumentType * -DocumentTypeRepo::getDocumentType(const stringref &name) const { +DocumentTypeRepo::getDocumentType(stringref name) const { DocumentTypeMap::const_iterator it = _doc_types->find(DocumentType::createId(name)); if (it != _doc_types->end() && it->second->doc_type->getName() == name) { @@ -544,7 +544,7 @@ DocumentTypeRepo::getDataType(const DocumentType &doc_type, int32_t id) const { } const DataType * -DocumentTypeRepo::getDataType(const DocumentType &doc_type, const stringref &name) const { +DocumentTypeRepo::getDataType(const DocumentType &doc_type, stringref name) const { const DataTypeRepo *dt_repo = FindPtr(*_doc_types, doc_type.getId()); return dt_repo ? dt_repo->repo.lookup(name) : nullptr; } diff --git a/document/src/vespa/document/repo/documenttyperepo.h b/document/src/vespa/document/repo/documenttyperepo.h index c1c25204b3f..68e4087ca49 100644 --- a/document/src/vespa/document/repo/documenttyperepo.h +++ b/document/src/vespa/document/repo/documenttyperepo.h @@ -35,9 +35,9 @@ public: ~DocumentTypeRepo(); const DocumentType *getDocumentType(int32_t doc_type_id) const; - const DocumentType *getDocumentType(const vespalib::stringref &name) const; + const DocumentType *getDocumentType(vespalib::stringref name) const; const DataType *getDataType(const DocumentType &doc_type, int32_t id) const; - const DataType *getDataType(const DocumentType &doc_type, const vespalib::stringref &name) const; + const DataType *getDataType(const DocumentType &doc_type, vespalib::stringref name) const; const AnnotationType *getAnnotationType(const DocumentType &doc_type, int32_t id) const; void forEachDocumentType(vespalib::Closure1 &c) const; const DocumentType *getDefaultDocType() const { return _default; } diff --git a/document/src/vespa/document/select/branch.h b/document/src/vespa/document/select/branch.h index 5c010dfde8c..63c4cbe24d8 100644 --- a/document/src/vespa/document/select/branch.h +++ b/document/src/vespa/document/select/branch.h @@ -22,7 +22,7 @@ namespace select { class Branch : public Node { public: - Branch(const vespalib::stringref & name) : Node(name) {} + Branch(vespalib::stringref name) : Node(name) {} bool isLeafNode() const override { return false; } }; diff --git a/document/src/vespa/document/select/doctype.cpp b/document/src/vespa/document/select/doctype.cpp index 4ecb388f60d..4b42d451f70 100644 --- a/document/src/vespa/document/select/doctype.cpp +++ b/document/src/vespa/document/select/doctype.cpp @@ -24,7 +24,7 @@ namespace { } } -DocType::DocType(const vespalib::stringref& doctype) +DocType::DocType(vespalib::stringref doctype) : Node("DocType"), _doctype(doctype) { diff --git a/document/src/vespa/document/select/doctype.h b/document/src/vespa/document/select/doctype.h index c53794aba15..160a3461746 100644 --- a/document/src/vespa/document/select/doctype.h +++ b/document/src/vespa/document/select/doctype.h @@ -23,7 +23,7 @@ private: vespalib::string _doctype; public: - DocType(const vespalib::stringref& doctype); + DocType(vespalib::stringref doctype); ResultList contains(const Context&) const override; ResultList trace(const Context&, std::ostream& trace) const override; diff --git a/document/src/vespa/document/select/invalidconstant.cpp b/document/src/vespa/document/select/invalidconstant.cpp index 06271efe8bf..e0b5e61e1ba 100644 --- a/document/src/vespa/document/select/invalidconstant.cpp +++ b/document/src/vespa/document/select/invalidconstant.cpp @@ -6,7 +6,7 @@ namespace document::select { -InvalidConstant::InvalidConstant(const vespalib::stringref & value) +InvalidConstant::InvalidConstant(vespalib::stringref value) : Node(value) { } diff --git a/document/src/vespa/document/select/invalidconstant.h b/document/src/vespa/document/select/invalidconstant.h index 75a0ca7235b..b99d0f5a066 100644 --- a/document/src/vespa/document/select/invalidconstant.h +++ b/document/src/vespa/document/select/invalidconstant.h @@ -20,7 +20,7 @@ namespace select { class InvalidConstant : public Node { public: - explicit InvalidConstant(const vespalib::stringref &value); + explicit InvalidConstant(vespalib::stringref value); ResultList contains(const Context&) const override { return ResultList(Result::Invalid); } ResultList trace(const Context&, std::ostream& trace) const override; diff --git a/document/src/vespa/document/select/node.h b/document/src/vespa/document/select/node.h index 83e2ea3542d..24c0897ba95 100644 --- a/document/src/vespa/document/select/node.h +++ b/document/src/vespa/document/select/node.h @@ -30,7 +30,7 @@ public: typedef std::unique_ptr UP; typedef std::shared_ptr SP; - Node(const vespalib::stringref & name) : _name(name), _parentheses(false) {} + Node(vespalib::stringref name) : _name(name), _parentheses(false) {} ~Node() override {} void setParentheses() { _parentheses = true; } diff --git a/document/src/vespa/document/select/operator.cpp b/document/src/vespa/document/select/operator.cpp index b2e7ddd82b8..8deb19452f0 100644 --- a/document/src/vespa/document/select/operator.cpp +++ b/document/src/vespa/document/select/operator.cpp @@ -13,7 +13,7 @@ namespace document::select { Operator::OperatorMap Operator::_operators; -Operator::Operator(const vespalib::stringref & name) +Operator::Operator(vespalib::stringref name) : _name(name) { OperatorMap::iterator it = _operators.find(name); @@ -24,7 +24,7 @@ Operator::Operator(const vespalib::stringref & name) } const Operator& -Operator::get(const vespalib::stringref & name) +Operator::get(vespalib::stringref name) { OperatorMap::iterator it = _operators.find(name); if (it == _operators.end()) { @@ -75,7 +75,7 @@ FunctionOperator::LT("<", &Value::operator<); const FunctionOperator FunctionOperator::NE("!=", &Value::operator!=); -RegexOperator::RegexOperator(const vespalib::stringref & name) +RegexOperator::RegexOperator(vespalib::stringref name) : Operator(name) { } @@ -133,7 +133,7 @@ RegexOperator::match(const vespalib::string& val, const vespalib::stringref & ex const RegexOperator RegexOperator::REGEX("=~"); -GlobOperator::GlobOperator(const vespalib::stringref & name) +GlobOperator::GlobOperator(vespalib::stringref name) : RegexOperator(name) { } @@ -187,7 +187,7 @@ GlobOperator::traceImpl(const Value& a, const Value& b, std::ostream& ost) const } vespalib::string -GlobOperator::convertToRegex(const vespalib::stringref & globpattern) const +GlobOperator::convertToRegex(vespalib::stringref globpattern) const { vespalib::asciistream ost; ost << '^'; @@ -219,7 +219,7 @@ GlobOperator::convertToRegex(const vespalib::stringref & globpattern) const } bool -GlobOperator::containsVariables(const vespalib::stringref & expression) +GlobOperator::containsVariables(vespalib::stringref expression) { for (size_t i=0, n=expression.size(); i(getValue()); } bool isUserSpec() const { return getId().getType() == IdValueNode::USER; } private: @@ -54,7 +54,7 @@ private: class OperatorParser : public Parser { public: - bool parse(const vespalib::stringref & s) override; + bool parse(vespalib::stringref s) override; const Operator * getOperator() const { return _operator; } private: const Operator *_operator; @@ -63,13 +63,13 @@ private: class StringParser : public Parser, public ValueResult { public: - bool parse(const vespalib::stringref & s) override; + bool parse(vespalib::stringref s) override; }; class IntegerParser : public Parser, public ValueResult { public: - bool parse(const vespalib::stringref & s) override; + bool parse(vespalib::stringref s) override; }; class SelectionParser : public Parser, public NodeResult @@ -78,7 +78,7 @@ public: SelectionParser(const BucketIdFactory& bucketIdFactory) : _bucketIdFactory(bucketIdFactory) {} - bool parse(const vespalib::stringref & s) override; + bool parse(vespalib::stringref s) override; private: const BucketIdFactory & _bucketIdFactory; }; diff --git a/document/src/vespa/document/select/value.cpp b/document/src/vespa/document/select/value.cpp index e20d6859c18..d6c94216bca 100644 --- a/document/src/vespa/document/select/value.cpp +++ b/document/src/vespa/document/select/value.cpp @@ -96,7 +96,7 @@ NullValue::print(std::ostream& out, bool verbose, out << "nil"; } -StringValue::StringValue(const vespalib::stringref & val) +StringValue::StringValue(vespalib::stringref val) : Value(String), _value(val) { diff --git a/document/src/vespa/document/select/value.h b/document/src/vespa/document/select/value.h index 6976bc40d63..f240f2ba5d7 100644 --- a/document/src/vespa/document/select/value.h +++ b/document/src/vespa/document/select/value.h @@ -91,7 +91,7 @@ class StringValue : public Value vespalib::string _value; public: - StringValue(const vespalib::stringref & val); + StringValue(vespalib::stringref val); const vespalib::string& getValue() const { return _value; } ResultList operator<(const Value& value) const override; diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp index f9cf3472110..52df1ed6dcc 100644 --- a/document/src/vespa/document/select/valuenodes.cpp +++ b/document/src/vespa/document/select/valuenodes.cpp @@ -38,7 +38,7 @@ namespace { } } -InvalidValueNode::InvalidValueNode(const vespalib::stringref & name) +InvalidValueNode::InvalidValueNode(vespalib::stringref name) : _name(name) { } @@ -79,7 +79,7 @@ NullValueNode::print(std::ostream& out, bool verbose, if (hadParentheses()) out << ')'; } -StringValueNode::StringValueNode(const vespalib::stringref & val) +StringValueNode::StringValueNode(vespalib::stringref val) : _value(val) { } @@ -686,7 +686,7 @@ namespace { } } -FunctionValueNode::FunctionValueNode(const vespalib::stringref & name, +FunctionValueNode::FunctionValueNode(vespalib::stringref name, std::unique_ptr src) : _function(), _funcname(name), diff --git a/document/src/vespa/document/select/valuenodes.h b/document/src/vespa/document/select/valuenodes.h index bc1ec0e01e8..2f5031abce7 100644 --- a/document/src/vespa/document/select/valuenodes.h +++ b/document/src/vespa/document/select/valuenodes.h @@ -19,7 +19,7 @@ class InvalidValueNode : public ValueNode { vespalib::string _name; public: - InvalidValueNode(const vespalib::stringref & name); + InvalidValueNode(vespalib::stringref name); std::unique_ptr getValue(const Context&) const override { return std::unique_ptr(new InvalidValue()); @@ -55,7 +55,7 @@ class StringValueNode : public ValueNode { vespalib::string _value; public: - explicit StringValueNode(const vespalib::stringref & val); + explicit StringValueNode(vespalib::stringref val); const vespalib::string& getValue() const { return _value; } @@ -280,7 +280,7 @@ class FunctionValueNode : public ValueNode public: enum Function { LOWERCASE, HASH, ABS }; - FunctionValueNode(const vespalib::stringref & name, std::unique_ptr src); + FunctionValueNode(vespalib::stringref name, std::unique_ptr src); Function getFunction() const { return _function; } const vespalib::string &getFunctionName(void) const { return _funcname; } diff --git a/document/src/vespa/document/util/stringutil.cpp b/document/src/vespa/document/util/stringutil.cpp index a80f3ead21e..60bc2516b77 100644 --- a/document/src/vespa/document/util/stringutil.cpp +++ b/document/src/vespa/document/util/stringutil.cpp @@ -127,7 +127,7 @@ const vespalib::string & StringUtil::escape(const vespalib::string & source, ves return source; } -vespalib::string StringUtil::unescape(const vespalib::stringref & source) +vespalib::string StringUtil::unescape(vespalib::stringref source) { vespalib::asciistream ost; for (unsigned int i=0; i 2 && str[0] == '[') { return createPolicyDirective(str.substr(1, str.size() - 2)); diff --git a/messagebus/src/vespa/messagebus/routing/routeparser.h b/messagebus/src/vespa/messagebus/routing/routeparser.h index 8ffba3f6e11..7a0c5a7f14a 100644 --- a/messagebus/src/vespa/messagebus/routing/routeparser.h +++ b/messagebus/src/vespa/messagebus/routing/routeparser.h @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include #include "hop.h" #include "route.h" @@ -15,12 +14,12 @@ namespace mbus { class RouteParser { private: static bool isWhitespace(char c); - static IHopDirective::SP createDirective(const vespalib::stringref &str); - static IHopDirective::SP createErrorDirective(const vespalib::stringref &str); - static IHopDirective::SP createPolicyDirective(const vespalib::stringref &str); - static IHopDirective::SP createRouteDirective(const vespalib::stringref &str); - static IHopDirective::SP createTcpDirective(const vespalib::stringref &str); - static IHopDirective::SP createVerbatimDirective(const vespalib::stringref &str); + static IHopDirective::SP createDirective(vespalib::stringref str); + static IHopDirective::SP createErrorDirective(vespalib::stringref str); + static IHopDirective::SP createPolicyDirective(vespalib::stringref str); + static IHopDirective::SP createRouteDirective(vespalib::stringref str); + static IHopDirective::SP createTcpDirective(vespalib::stringref str); + static IHopDirective::SP createVerbatimDirective(vespalib::stringref str); public: /** diff --git a/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp b/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp index 2b6774a9412..7dd7672712d 100644 --- a/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp +++ b/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp @@ -5,7 +5,7 @@ namespace mbus { -TcpDirective::TcpDirective(const vespalib::stringref &host, uint32_t port, const vespalib::stringref &session) : +TcpDirective::TcpDirective(vespalib::stringref host, uint32_t port, const vespalib::stringref &session) : _host(host), _port(port), _session(session) diff --git a/messagebus/src/vespa/messagebus/routing/tcpdirective.h b/messagebus/src/vespa/messagebus/routing/tcpdirective.h index 8687298049f..c38d131b6a3 100644 --- a/messagebus/src/vespa/messagebus/routing/tcpdirective.h +++ b/messagebus/src/vespa/messagebus/routing/tcpdirective.h @@ -26,7 +26,7 @@ public: * @param port The port to connect to. * @param session The session to route to. */ - TcpDirective(const vespalib::stringref &host, uint32_t port, const vespalib::stringref &session); + TcpDirective(vespalib::stringref host, uint32_t port, const vespalib::stringref &session); /** * Returns the host to connect to. This may be an ip address or a name. diff --git a/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp b/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp index 86f50d897a5..f4c768bfd59 100644 --- a/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp +++ b/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp @@ -4,7 +4,7 @@ namespace mbus { -VerbatimDirective::VerbatimDirective(const vespalib::stringref &image) : +VerbatimDirective::VerbatimDirective(vespalib::stringref image) : _image(image) { // empty diff --git a/messagebus/src/vespa/messagebus/routing/verbatimdirective.h b/messagebus/src/vespa/messagebus/routing/verbatimdirective.h index 5745937380e..fe42c35505c 100644 --- a/messagebus/src/vespa/messagebus/routing/verbatimdirective.h +++ b/messagebus/src/vespa/messagebus/routing/verbatimdirective.h @@ -22,7 +22,7 @@ public: * * @param image The image to assign to this. */ - VerbatimDirective(const vespalib::stringref &image); + VerbatimDirective(vespalib::stringref image); /** * Returns the image to which this is a verbatim match. diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp index 39a9fdefc39..2e87f26badb 100644 --- a/metrics/src/vespa/metrics/metricmanager.cpp +++ b/metrics/src/vespa/metrics/metricmanager.cpp @@ -189,7 +189,7 @@ namespace { struct Path { vespalib::StringTokenizer _path; - Path(const vespalib::stringref & fullpath) : _path(fullpath, ".") { } + Path(vespalib::stringref fullpath) : _path(fullpath, ".") { } vespalib::string toString() const { vespalib::asciistream ost; diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.cpp b/searchcommon/src/vespa/searchcommon/common/datatype.cpp index 81e6b8a1f34..f3b2099294e 100644 --- a/searchcommon/src/vespa/searchcommon/common/datatype.cpp +++ b/searchcommon/src/vespa/searchcommon/common/datatype.cpp @@ -10,7 +10,7 @@ namespace search::index::schema { using config::InvalidConfigException; DataType -dataTypeFromName(const vespalib::stringref &name) { +dataTypeFromName(vespalib::stringref name) { if (name == "UINT1") { return DataType::UINT1; } else if (name == "UINT2") { return DataType::UINT2; } else if (name == "UINT4") { return DataType::UINT4; } @@ -65,7 +65,7 @@ operator<<(std::ostream &os, const DataType &type) } CollectionType -collectionTypeFromName(const vespalib::stringref &name) { +collectionTypeFromName(vespalib::stringref name) { if (name == "SINGLE") { return CollectionType::SINGLE; } else if (name == "ARRAY") { return CollectionType::ARRAY; } else if (name == "WEIGHTEDSET") { return CollectionType::WEIGHTEDSET; } diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.h b/searchcommon/src/vespa/searchcommon/common/datatype.h index ad762b9acc4..f21b6b9d5e9 100644 --- a/searchcommon/src/vespa/searchcommon/common/datatype.h +++ b/searchcommon/src/vespa/searchcommon/common/datatype.h @@ -34,11 +34,11 @@ enum class CollectionType { SINGLE = 0, WEIGHTEDSET = 2 }; -DataType dataTypeFromName(const vespalib::stringref &name); +DataType dataTypeFromName(vespalib::stringref name); vespalib::string getTypeName(DataType type); std::ostream &operator<<(std::ostream &os, const DataType &type); -CollectionType collectionTypeFromName(const vespalib::stringref &n); +CollectionType collectionTypeFromName(vespalib::stringref n); vespalib::string getTypeName(CollectionType type); std::ostream &operator<<(std::ostream &os, const CollectionType &type); diff --git a/searchcommon/src/vespa/searchcommon/common/schema.cpp b/searchcommon/src/vespa/searchcommon/common/schema.cpp index 6cd9d87fa77..775199694c0 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.cpp +++ b/searchcommon/src/vespa/searchcommon/common/schema.cpp @@ -55,7 +55,7 @@ struct FieldName { template uint32_t -getFieldId(const vespalib::stringref & name, const T &map) +getFieldId(vespalib::stringref name, const T &map) { typename T::const_iterator it = map.find(name); return (it != map.end()) ? it->second : Schema::UNKNOWN_FIELD_ID; @@ -68,7 +68,7 @@ namespace index { const uint32_t Schema::UNKNOWN_FIELD_ID(std::numeric_limits::max()); -Schema::Field::Field(const vespalib::stringref &n, DataType dt) +Schema::Field::Field(vespalib::stringref n, DataType dt) : _name(n), _dataType(dt), _collectionType(schema::CollectionType::SINGLE), @@ -76,7 +76,7 @@ Schema::Field::Field(const vespalib::stringref &n, DataType dt) { } -Schema::Field::Field(const vespalib::stringref &n, +Schema::Field::Field(vespalib::stringref n, DataType dt, CollectionType ct) : _name(n), _dataType(dt), @@ -128,7 +128,7 @@ Schema::Field::operator!=(const Field &rhs) const _timestamp != rhs._timestamp; } -Schema::IndexField::IndexField(const vespalib::stringref &name, DataType dt) +Schema::IndexField::IndexField(vespalib::stringref name, DataType dt) : Field(name, dt), _prefix(false), _phrases(false), @@ -137,7 +137,7 @@ Schema::IndexField::IndexField(const vespalib::stringref &name, DataType dt) { } -Schema::IndexField::IndexField(const vespalib::stringref &name, DataType dt, +Schema::IndexField::IndexField(vespalib::stringref name, DataType dt, CollectionType ct) : Field(name, dt, ct), _prefix(false), @@ -398,25 +398,25 @@ Schema::addFieldSet(const FieldSet &fieldSet) } uint32_t -Schema::getIndexFieldId(const vespalib::stringref & name) const +Schema::getIndexFieldId(vespalib::stringref name) const { return getFieldId(name, _indexIds); } uint32_t -Schema::getAttributeFieldId(const vespalib::stringref & name) const +Schema::getAttributeFieldId(vespalib::stringref name) const { return getFieldId(name, _attributeIds); } uint32_t -Schema::getSummaryFieldId(const vespalib::stringref & name) const +Schema::getSummaryFieldId(vespalib::stringref name) const { return getFieldId(name, _summaryIds); } uint32_t -Schema::getFieldSetId(const vespalib::stringref &name) const +Schema::getFieldSetId(vespalib::stringref name) const { return getFieldId(name, _fieldSetIds); } diff --git a/searchcommon/src/vespa/searchcommon/common/schema.h b/searchcommon/src/vespa/searchcommon/common/schema.h index 1c3ab3ccd56..52de8646cc1 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.h +++ b/searchcommon/src/vespa/searchcommon/common/schema.h @@ -38,8 +38,8 @@ public: fastos::TimeStamp _timestamp; public: - Field(const vespalib::stringref &n, DataType dt); - Field(const vespalib::stringref &n, DataType dt, CollectionType ct); + Field(vespalib::stringref n, DataType dt); + Field(vespalib::stringref n, DataType dt, CollectionType ct); /** * Create this field based on the given config lines. @@ -81,8 +81,8 @@ public: uint32_t _avgElemLen; public: - IndexField(const vespalib::stringref &name, DataType dt); - IndexField(const vespalib::stringref &name, DataType dt, CollectionType ct); + IndexField(vespalib::stringref name, DataType dt); + IndexField(vespalib::stringref name, DataType dt, CollectionType ct); /** * Create this index field based on the given config lines. **/ @@ -122,7 +122,7 @@ public: std::vector _fields; public: - FieldSet(const vespalib::stringref & n) : _name(n), _fields() {} + FieldSet(vespalib::stringref n) : _name(n), _fields() {} /** * Create this field collection based on the given config lines. @@ -131,7 +131,7 @@ public: ~FieldSet(); - FieldSet &addField(const vespalib::stringref &fieldName) { + FieldSet &addField(vespalib::stringref fieldName) { _fields.push_back(fieldName); return *this; } @@ -285,7 +285,7 @@ public: * @return the field id or UNKNOWN_FIELD_ID if not found. * @param name the name of the field. **/ - uint32_t getIndexFieldId(const vespalib::stringref & name) const; + uint32_t getIndexFieldId(vespalib::stringref name) const; /** * Check if a field is an index @@ -294,7 +294,7 @@ public: * @param name the name of the field. **/ bool - isIndexField(const vespalib::stringref & name) const + isIndexField(vespalib::stringref name) const { return _indexIds.find(name) != _indexIds.end(); } @@ -306,7 +306,7 @@ public: * @param name the name of the field. **/ bool - isSummaryField(const vespalib::stringref & name) const + isSummaryField(vespalib::stringref name) const { return _summaryIds.find(name) != _summaryIds.end(); } @@ -317,7 +317,7 @@ public: * @param name the name of the field. **/ bool - isAttributeField(const vespalib::stringref & name) const + isAttributeField(vespalib::stringref name) const { return _attributeIds.find(name) != _attributeIds.end(); } @@ -347,7 +347,7 @@ public: * @return the field id or UNKNOWN_FIELD_ID if not found. * @param name the name of the field. **/ - uint32_t getAttributeFieldId(const vespalib::stringref & name) const; + uint32_t getAttributeFieldId(vespalib::stringref name) const; /** * Get information about a specific summary field using the given fieldId. @@ -374,7 +374,7 @@ public: * @return the field id or UNKNOWN_FIELD_ID if not found. * @param name the name of the field. **/ - uint32_t getSummaryFieldId(const vespalib::stringref & name) const; + uint32_t getSummaryFieldId(vespalib::stringref name) const; /** * Get information about a specific field set @@ -395,7 +395,7 @@ public: * @param name the name of the field set. **/ uint32_t - getFieldSetId(const vespalib::stringref &name) const; + getFieldSetId(vespalib::stringref name) const; const std::vector &getImportedAttributeFields() const { return _importedAttributeFields; diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp index 48c7110ff9f..d50a2aed46a 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp @@ -35,7 +35,7 @@ FastS_query::FastS_query(const search::docsummary::GetDocsumArgs &docsumArgs) void -FastS_query::SetStackDump(const vespalib::stringref &stackRef) +FastS_query::SetStackDump(vespalib::stringref stackRef) { _stackDump = stackRef; } diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/query.h b/searchcore/src/vespa/searchcore/fdispatch/search/query.h index 4d336d9843e..0e5d6008c36 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/query.h +++ b/searchcore/src/vespa/searchcore/fdispatch/search/query.h @@ -25,7 +25,7 @@ public: FastS_query(const search::docsummary::GetDocsumArgs &docsumArgs); ~FastS_query(); - void SetStackDump(const vespalib::stringref& stackDump); + void SetStackDump(vespalib::stringref stackDump); void SetSortSpec(const char *spec) { _sortSpec = spec; } void SetLocation(const char *loc) { _location = loc; } void SetRankProperties(const search::fef::Properties &rp) { _rankProperties = rp; } @@ -66,7 +66,7 @@ private: return false; return (strcmp(a, b) == 0); } - static bool cmp_str_ref(const vespalib::stringref &a, + static bool cmp_str_ref(vespalib::stringref a, const vespalib::stringref &b) { return (a.size() == b.size() && diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp index 90c6fa2155c..daaf2a7c1db 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp @@ -15,7 +15,7 @@ SearchPath::Element::Element() } vespalib::stringref -SearchPath::parseElement(const vespalib::stringref &spec, size_t numNodes) +SearchPath::parseElement(vespalib::stringref spec, size_t numNodes) { _elements.push_back(Element()); vespalib::string::size_type specSepPos(spec.find('/')); @@ -32,7 +32,7 @@ SearchPath::parseElement(const vespalib::stringref &spec, size_t numNodes) } void -SearchPath::parsePartList(const vespalib::stringref &partSpec, size_t numNodes) +SearchPath::parsePartList(vespalib::stringref partSpec, size_t numNodes) { try { if (!partSpec.empty() && (partSpec[0] != '*')) { @@ -94,7 +94,7 @@ SearchPath::parsePartRange(vespalib::asciistream &spec, size_t numNodes) } void -SearchPath::parseRow(const vespalib::stringref &rowSpec) +SearchPath::parseRow(vespalib::stringref rowSpec) { if (!rowSpec.empty()) { // FIXME C++17 range-safe from_chars() instead of strtoul() diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h index 847fb525b95..bbf1002742e 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h +++ b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h @@ -43,11 +43,11 @@ public: private: ElementVector _elements; - vespalib::stringref parseElement(const vespalib::stringref &spec, size_t numNodes); - void parsePartList(const vespalib::stringref &partSpec, size_t numNodes); + vespalib::stringref parseElement(vespalib::stringref spec, size_t numNodes); + void parsePartList(vespalib::stringref partSpec, size_t numNodes); void parsePartList(vespalib::asciistream &spec, size_t numNodes); void parsePartRange(vespalib::asciistream &spec, size_t numNodes); - void parseRow(const vespalib::stringref &rowSpec); + void parseRow(vespalib::stringref rowSpec); public: SearchPath(const vespalib::string &spec, size_t numNodes); diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp index ca96033c358..c7a1b7749e1 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp @@ -44,7 +44,7 @@ vespalib::string LOOSE_STR("loose"); } AttributeLimiter::DiversityCutoffStrategy -AttributeLimiter::toDiversityCutoffStrategy(const vespalib::stringref & strategy) +AttributeLimiter::toDiversityCutoffStrategy(vespalib::stringref strategy) { return (strategy == STRICT_STR) ? DiversityCutoffStrategy::STRICT : DiversityCutoffStrategy::LOOSE; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h index 0c23ea05fbd..63574ce3dcf 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h +++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h @@ -34,7 +34,7 @@ public: search::queryeval::SearchIterator::UP create_search(size_t want_hits, size_t max_group_size, bool strictSearch); bool was_used() const { return ((!_match_datas.empty()) || (_blueprint.get() != nullptr)); } ssize_t getEstimatedHits() const { return _estimatedHits; } - static DiversityCutoffStrategy toDiversityCutoffStrategy(const vespalib::stringref & strategy); + static DiversityCutoffStrategy toDiversityCutoffStrategy(vespalib::stringref strategy); private: const vespalib::string & toString(DiversityCutoffStrategy strategy); search::queryeval::Searchable & _searchable_attributes; diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index e550ad8cad7..a8f75928a6d 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -103,7 +103,7 @@ Query::Query() = default; Query::~Query() = default; bool -Query::buildTree(const vespalib::stringref &stack, const string &location, +Query::buildTree(vespalib::stringref stack, const string &location, const ViewResolver &resolver, const IIndexEnvironment &indexEnv) { SimpleQueryStackDumpIterator stack_dump_iterator(stack); diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h index 21365f75133..58d1d249ce6 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.h +++ b/searchcore/src/vespa/searchcore/proton/matching/query.h @@ -32,7 +32,7 @@ public: * * @return success(true)/failure(false) **/ - bool buildTree(const vespalib::stringref &stack, + bool buildTree(vespalib::stringref stack, const vespalib::string &location, const ViewResolver &resolver, const search::fef::IIndexEnvironment &idxEnv); diff --git a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp index b1442fe5e92..d8676357633 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp @@ -6,7 +6,7 @@ namespace proton::matching { ViewResolver & -ViewResolver::add(const vespalib::stringref &view, +ViewResolver::add(vespalib::stringref view, const vespalib::stringref &field) { _map[view].push_back(field); @@ -14,7 +14,7 @@ ViewResolver::add(const vespalib::stringref &view, } bool -ViewResolver::resolve(const vespalib::stringref &view, +ViewResolver::resolve(vespalib::stringref view, std::vector &fields) const { Map::const_iterator pos = _map.find(view); diff --git a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h index 124ebc67d52..3899167ebc0 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h +++ b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h @@ -34,7 +34,7 @@ public: * @param view the name of the view * @param field the name of the field **/ - ViewResolver &add(const vespalib::stringref &view, + ViewResolver &add(vespalib::stringref view, const vespalib::stringref &field); /** @@ -47,7 +47,7 @@ public: * @param fields vector that will be filled out with the fields * that are part of the requested view. **/ - bool resolve(const vespalib::stringref &view, + bool resolve(vespalib::stringref view, std::vector &fields) const; /** diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp index 3180f7ed29d..ba2b0b962f6 100644 --- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp +++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp @@ -1,5 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include "factoryloader.h" #include using vespalib::stringref; @@ -13,18 +13,16 @@ FactoryLoader::FactoryLoader() : { } -FactoryLoader::~FactoryLoader() -{ -} +FactoryLoader::~FactoryLoader() = default; IIndexManagerFactory::UP -FactoryLoader::create(const stringref & factory) +FactoryLoader::create(stringref factory) { typedef IIndexManagerFactory* (*FuncT)(); _libraries.loadLibrary(factory); const FastOS_DynamicLibrary & lib = *_libraries.get(factory); FuncT registrationMethod = reinterpret_cast(lib.GetSymbol("createIndexManagerFactory")); - if (registrationMethod == NULL) { + if (registrationMethod == nullptr) { throw IllegalArgumentException(make_string("Failed locating symbol 'createIndexManagerFactory' in library '%s' for factory '%s'.", lib.GetLibName(), vespalib::string(factory).c_str())); } diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h index e581b540dff..0e464156f73 100644 --- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h +++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h @@ -17,7 +17,7 @@ public: * @param the name of the library. Like 'vesparise'. * @return the factory that is created. */ - IIndexManagerFactory::UP create(const vespalib::stringref & factory); + IIndexManagerFactory::UP create(vespalib::stringref factory); private: vespalib::LibraryPool _libraries; }; diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp index 683b1e420b5..3e4a5c2bcfa 100644 --- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp +++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp @@ -9,15 +9,11 @@ using vespalib::string; namespace searchcorespi { -FactoryRegistry::FactoryRegistry() -{ -} +FactoryRegistry::FactoryRegistry() = default; -FactoryRegistry::~FactoryRegistry() -{ -} +FactoryRegistry::~FactoryRegistry() = default; -void FactoryRegistry::add(const stringref & uniqueName, const IIndexManagerFactory::SP & factory) +void FactoryRegistry::add(stringref uniqueName, const IIndexManagerFactory::SP & factory) { LockGuard guard(_lock); if (_registry.find(uniqueName) == _registry.end()) { @@ -27,7 +23,7 @@ void FactoryRegistry::add(const stringref & uniqueName, const IIndexManagerFacto } } -void FactoryRegistry::remove(const stringref & uniqueName) +void FactoryRegistry::remove(stringref uniqueName) { LockGuard guard(_lock); if (_registry.find(uniqueName) == _registry.end()) { @@ -37,7 +33,7 @@ void FactoryRegistry::remove(const stringref & uniqueName) } const IIndexManagerFactory::SP & -FactoryRegistry::get(const stringref & uniqueName) const +FactoryRegistry::get(stringref uniqueName) const { LockGuard guard(_lock); Registry::const_iterator found = _registry.find(uniqueName); @@ -48,7 +44,7 @@ FactoryRegistry::get(const stringref & uniqueName) const } bool -FactoryRegistry::isRegistered(const vespalib::stringref & uniqueName) const +FactoryRegistry::isRegistered(vespalib::stringref uniqueName) const { LockGuard guard(_lock); Registry::const_iterator found = _registry.find(uniqueName); diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h index 64cc75721d8..ce9f4d1813d 100644 --- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h +++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h @@ -22,23 +22,23 @@ public: * @param factory The factory instance for producing IndexManagers. * @throws vespalib::IllegalArgument if factory is already registered. */ - void add(const vespalib::stringref & uniqueName, const IIndexManagerFactory::SP & factory); + void add(vespalib::stringref uniqueName, const IIndexManagerFactory::SP & factory); /** * Will unregister a factory. Should be called when a sharedlibrary is being unloaded. * @param uniqueName Unique name of factory to remove from registry. * @throws vespalib::IllegalArgument if factory is already registered. */ - void remove(const vespalib::stringref & uniqueName); + void remove(vespalib::stringref uniqueName); /** * This method will fetch a factory given its unique name. * @param name The name of the factory to return. * @return The factory. */ - const IIndexManagerFactory::SP & get(const vespalib::stringref & uniqueName) const; + const IIndexManagerFactory::SP & get(vespalib::stringref uniqueName) const; /** * Returns true if a factory with the given name has been registered. */ - bool isRegistered(const vespalib::stringref & uniqueName) const; + bool isRegistered(vespalib::stringref uniqueName) const; private: typedef std::map Registry; -- cgit v1.2.3