diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-07 11:16:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-07 11:16:35 +0000 |
commit | 9bb9d8e14827ecc4dba2d43e2d9e76248c120e1d (patch) | |
tree | 9e64c1471c0391410c824f75e2dc1fbfa8585229 | |
parent | f2e89d3361cae0e2e74bac89405a175d6ecf5e98 (diff) |
Add noexcept as indicated by -Wnoeexcept
146 files changed, 471 insertions, 548 deletions
diff --git a/document/src/vespa/document/repo/documenttyperepo.cpp b/document/src/vespa/document/repo/documenttyperepo.cpp index bcd4edb3ab8..677da16190d 100644 --- a/document/src/vespa/document/repo/documenttyperepo.cpp +++ b/document/src/vespa/document/repo/documenttyperepo.cpp @@ -547,13 +547,13 @@ DocumentTypeRepo::~DocumentTypeRepo() { } const DocumentType * -DocumentTypeRepo::getDocumentType(int32_t type_id) const { +DocumentTypeRepo::getDocumentType(int32_t type_id) const noexcept { const DataTypeRepo *repo = FindPtr(*_doc_types, type_id); return repo ? repo->doc_type : nullptr; } const DocumentType * -DocumentTypeRepo::getDocumentType(stringref name) const { +DocumentTypeRepo::getDocumentType(stringref name) const noexcept { DocumentTypeMap::const_iterator it = _doc_types->find(DocumentType::createId(name)); if (it != _doc_types->end() && it->second->doc_type->getName() == name) { diff --git a/document/src/vespa/document/repo/documenttyperepo.h b/document/src/vespa/document/repo/documenttyperepo.h index f0c59918a74..fd17bd5640a 100644 --- a/document/src/vespa/document/repo/documenttyperepo.h +++ b/document/src/vespa/document/repo/documenttyperepo.h @@ -34,8 +34,8 @@ public: explicit DocumentTypeRepo(const DocumenttypesConfig & config); ~DocumentTypeRepo(); - const DocumentType *getDocumentType(int32_t doc_type_id) const; - const DocumentType *getDocumentType(vespalib::stringref name) const; + const DocumentType *getDocumentType(int32_t doc_type_id) const noexcept; + const DocumentType *getDocumentType(vespalib::stringref name) const noexcept; const DataType *getDataType(const DocumentType &doc_type, int32_t id) const; const DataType *getDataType(const DocumentType &doc_type, vespalib::stringref name) const; const AnnotationType *getAnnotationType(const DocumentType &doc_type, int32_t id) const; diff --git a/document/src/vespa/document/repo/fixedtyperepo.cpp b/document/src/vespa/document/repo/fixedtyperepo.cpp index 81a26265830..20865a8a6ca 100644 --- a/document/src/vespa/document/repo/fixedtyperepo.cpp +++ b/document/src/vespa/document/repo/fixedtyperepo.cpp @@ -5,7 +5,7 @@ namespace document { -FixedTypeRepo::FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type) +FixedTypeRepo::FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type) noexcept : _repo(&repo), _doc_type(repo.getDocumentType(type)) { assert(_doc_type); diff --git a/document/src/vespa/document/repo/fixedtyperepo.h b/document/src/vespa/document/repo/fixedtyperepo.h index 67e7571e31d..29bef846e36 100644 --- a/document/src/vespa/document/repo/fixedtyperepo.h +++ b/document/src/vespa/document/repo/fixedtyperepo.h @@ -13,17 +13,17 @@ class FixedTypeRepo { const DocumentType *_doc_type; public: - explicit FixedTypeRepo(const DocumentTypeRepo &repo) + explicit FixedTypeRepo(const DocumentTypeRepo &repo) noexcept : _repo(&repo), _doc_type(repo.getDefaultDocType()) {} - FixedTypeRepo(const DocumentTypeRepo &repo, const DocumentType &doc_type) + FixedTypeRepo(const DocumentTypeRepo &repo, const DocumentType &doc_type) noexcept : _repo(&repo), _doc_type(&doc_type) {} - FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type); + FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type) noexcept; const DataType *getDataType(int32_t id) const { return _repo->getDataType(*_doc_type, id); } const DataType *getDataType(const vespalib::string &name) const { return _repo->getDataType(*_doc_type, name); } const AnnotationType *getAnnotationType(int32_t id) const { return _repo->getAnnotationType(*_doc_type, id); } const DocumentTypeRepo &getDocumentTypeRepo() const { return *_repo; } - const DocumentType &getDocumentType() const { return *_doc_type; } + const DocumentType &getDocumentType() const noexcept { return *_doc_type; } }; } // namespace document diff --git a/eval/src/tests/ann/hnsw-like.h b/eval/src/tests/ann/hnsw-like.h index 841957c1ccb..ac4a346993d 100644 --- a/eval/src/tests/ann/hnsw-like.h +++ b/eval/src/tests/ann/hnsw-like.h @@ -86,7 +86,7 @@ struct VisitedSetPool struct HnswHit { double dist; uint32_t docid; - HnswHit(uint32_t di, SqDist sq) : dist(sq.distance), docid(di) {} + HnswHit(uint32_t di, SqDist sq) noexcept : dist(sq.distance), docid(di) {} }; struct GreaterDist { diff --git a/eval/src/tests/ann/nns.h b/eval/src/tests/ann/nns.h index 7a20a132248..6351733fb59 100644 --- a/eval/src/tests/ann/nns.h +++ b/eval/src/tests/ann/nns.h @@ -8,13 +8,13 @@ struct SqDist { double distance; - explicit SqDist(double d) : distance(d) {} + explicit SqDist(double d) noexcept : distance(d) {} }; struct NnsHit { uint32_t docid; SqDist sq; - NnsHit(uint32_t di, SqDist sqD) + NnsHit(uint32_t di, SqDist sqD) noexcept : docid(di), sq(sqD) {} }; struct NnsHitComparatorLessDistance { diff --git a/fsa/src/vespa/fsa/fsa.h b/fsa/src/vespa/fsa/fsa.h index e4d3246d924..9c668f1f85f 100644 --- a/fsa/src/vespa/fsa/fsa.h +++ b/fsa/src/vespa/fsa/fsa.h @@ -304,7 +304,7 @@ public: * * @param f Reference to FSA. */ - State(const FSA& f) : _fsa(&f), _state(_fsa->start()) {} + State(const FSA& f) noexcept : _fsa(&f), _state(_fsa->start()) {} /** * @brief Constructor. @@ -314,7 +314,7 @@ public: * * @param f Pointer to FSA. */ - State(const FSA* f) : _fsa(f), _state(_fsa->start()) {} + State(const FSA* f) noexcept : _fsa(f), _state(_fsa->start()) {} /** * @brief Copy constructor. @@ -325,14 +325,14 @@ public: * * @param s Reference to state to be duplicated. */ - State(const State& s) : _fsa(s._fsa), _state(s._state) {} + State(const State& s) noexcept : _fsa(s._fsa), _state(s._state) {} /** * @brief Destructor. * * Destructor, does nothing special. */ - virtual ~State() {} + virtual ~State() = default; /** * @brief Check if the automaton has perfect hash built in. @@ -1043,7 +1043,7 @@ public: * * @param f Reference to FSA. */ - WordCounterState(const FSA& f) : State(f), _counter(0) {} + WordCounterState(const FSA& f) noexcept : State(f), _counter(0) {} /** * @brief Constructor. @@ -1053,7 +1053,7 @@ public: * * @param f Pointer to FSA. */ - WordCounterState(const FSA* f) : State(f), _counter(0) {} + WordCounterState(const FSA* f) noexcept : State(f), _counter(0) {} /** * @brief Copy constructor. @@ -1062,12 +1062,12 @@ public: * * @param s Reference to hashed state to copy. */ - WordCounterState(const WordCounterState& s) : State(s), _counter(s._counter) {} + WordCounterState(const WordCounterState& s) noexcept : State(s), _counter(s._counter) {} /** * @brief Destructor. */ - virtual ~WordCounterState() {} + virtual ~WordCounterState() = default; /** * @brief Set the state to the starting state of the automaton. @@ -1798,7 +1798,7 @@ public: * * @param f Reference to FSA. */ - HashedWordCounterState(const FSA& f) : State(f), _hash(0), _counter(0) {} + HashedWordCounterState(const FSA& f) noexcept : State(f), _hash(0), _counter(0) {} /** * @brief Constructor. @@ -1808,7 +1808,7 @@ public: * * @param f Pointer to FSA. */ - HashedWordCounterState(const FSA* f) : State(f), _hash(0), _counter(0) {} + HashedWordCounterState(const FSA* f) noexcept : State(f), _hash(0), _counter(0) {} /** * @brief Copy constructor. @@ -1817,12 +1817,12 @@ public: * * @param s Reference to hashed state to copy. */ - HashedWordCounterState(const HashedWordCounterState& s) : State(s), _hash(s._hash), _counter(s._counter) {} + HashedWordCounterState(const HashedWordCounterState& s) noexcept : State(s), _hash(s._hash), _counter(s._counter) {} /** * @brief Destructor. */ - virtual ~HashedWordCounterState() {} + virtual ~HashedWordCounterState() = default; /** * @brief Set the state to the starting state of the automaton. @@ -2120,7 +2120,7 @@ public: * * @return Index of the start state (0 if the %FSA is empty). */ - state_t start() const + state_t start() const noexcept { return _start; } diff --git a/fsa/src/vespa/fsa/segmenter.h b/fsa/src/vespa/fsa/segmenter.h index a2720c6de0c..f2826f9c967 100644 --- a/fsa/src/vespa/fsa/segmenter.h +++ b/fsa/src/vespa/fsa/segmenter.h @@ -147,7 +147,7 @@ public: * * Null segment at postion zero. */ - Segment() : _beg(0), _end(0), _conn(0) {} + Segment() noexcept : _beg(0), _end(0), _conn(0) {} /** * @brief Constructor. @@ -156,7 +156,7 @@ public: * @param e End of the segment (the position after the last term). * @param c Connexity of the segment. */ - Segment(unsigned int b, unsigned int e, unsigned int c) : + Segment(unsigned int b, unsigned int e, unsigned int c) noexcept : _beg(b), _end(e), _conn(c) {} /** @@ -164,12 +164,12 @@ public: * * @param s Segment object to copy. */ - Segment(const Segment &s) : _beg(s._beg), _end(s._end), _conn(s._conn) {} + Segment(const Segment &s) noexcept : _beg(s._beg), _end(s._end), _conn(s._conn) {} /** * @brief Destructor. */ - ~Segment() {} + ~Segment() = default; /** * @brief Set the segment parameters. diff --git a/logd/src/tests/empty_forwarder/empty_forwarder_test.cpp b/logd/src/tests/empty_forwarder/empty_forwarder_test.cpp index d1194f30c40..dbc76e694f2 100644 --- a/logd/src/tests/empty_forwarder/empty_forwarder_test.cpp +++ b/logd/src/tests/empty_forwarder/empty_forwarder_test.cpp @@ -11,7 +11,7 @@ using vespalib::metrics::DummyMetricsManager; struct MockMetricsManager : public DummyMetricsManager { int add_count; - MockMetricsManager() : DummyMetricsManager(), add_count(0) {} + MockMetricsManager() noexcept : DummyMetricsManager(), add_count(0) {} void add(Counter::Increment) override { ++add_count; } diff --git a/logd/src/tests/rpc_forwarder/rpc_forwarder_test.cpp b/logd/src/tests/rpc_forwarder/rpc_forwarder_test.cpp index 15a1dc36a87..d39a9ade0a8 100644 --- a/logd/src/tests/rpc_forwarder/rpc_forwarder_test.cpp +++ b/logd/src/tests/rpc_forwarder/rpc_forwarder_test.cpp @@ -85,7 +85,7 @@ make_log_line(const std::string& level, const std::string& payload) struct MockMetricsManager : public DummyMetricsManager { int add_count; - MockMetricsManager() : DummyMetricsManager(), add_count(0) {} + MockMetricsManager() noexcept : DummyMetricsManager(), add_count(0) {} void add(Counter::Increment) override { ++add_count; } diff --git a/persistence/src/vespa/persistence/spi/bucket.h b/persistence/src/vespa/persistence/spi/bucket.h index 175aba376a9..b7d04150108 100644 --- a/persistence/src/vespa/persistence/spi/bucket.h +++ b/persistence/src/vespa/persistence/spi/bucket.h @@ -36,7 +36,7 @@ public: /** Convert easily to a document bucket id to make class easy to use. */ operator document::BucketId() const { return _bucket.getBucketId(); } - bool operator==(const Bucket& o) const { + bool operator==(const Bucket& o) const noexcept { return (_bucket == o._bucket && _partition == o._partition); } diff --git a/persistencetypes/src/persistence/spi/types.h b/persistencetypes/src/persistence/spi/types.h index c11f3dacf06..59891e04710 100644 --- a/persistencetypes/src/persistence/spi/types.h +++ b/persistencetypes/src/persistence/spi/types.h @@ -29,10 +29,10 @@ namespace document { typedef type Type; \ name() noexcept : _value() {} \ explicit name(type v) noexcept : _value(v) {} \ - operator type() const { return _value; } \ - operator type&() { return _value; } \ - type getValue() const { return _value; } \ - name& operator=(type val) { _value = val; return *this; } \ + operator type() const noexcept { return _value; } \ + operator type&() noexcept { return _value; } \ + type getValue() const noexcept { return _value; } \ + name& operator=(type val) noexcept { _value = val; return *this; } \ friend vespalib::nbostream & \ operator<<(vespalib::nbostream &os, const name &wrapped); \ friend vespalib::nbostream & \ diff --git a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h index 71319d782f1..c26906ac7c0 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h +++ b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h @@ -36,8 +36,8 @@ private: int32_t _weight; public: - WeightedType() : _value(T()), _weight(1) { } - WeightedType(T value_, int32_t weight_ = 1) : _value(value_), _weight(weight_) { } + WeightedType() noexcept : _value(T()), _weight(1) { } + WeightedType(T value_, int32_t weight_ = 1) noexcept : _value(value_), _weight(weight_) { } const T & getValue() const { return _value; } const T & value() const { return _value; } void setValue(const T & v) { _value = v; } diff --git a/searchcore/src/apps/vespa-feed-bm/bm_storage_link_context.h b/searchcore/src/apps/vespa-feed-bm/bm_storage_link_context.h index adb2a13ec10..f2df20f1f66 100644 --- a/searchcore/src/apps/vespa-feed-bm/bm_storage_link_context.h +++ b/searchcore/src/apps/vespa-feed-bm/bm_storage_link_context.h @@ -10,7 +10,7 @@ class BmStorageLink; struct BmStorageLinkContext { BmStorageLink* bm_link; - BmStorageLinkContext() + BmStorageLinkContext() noexcept : bm_link(nullptr) { } diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index b275064c0f2..e6751a0cb98 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -176,7 +176,7 @@ struct MyGidToLidChangeHandler : public MockGidToLidChangeHandler uint32_t _changes; std::map<document::GlobalId, uint32_t> _gidToLid; public: - MyGidToLidChangeHandler() + MyGidToLidChangeHandler() noexcept : MockGidToLidChangeHandler(), _changeGid(), _changeLid(std::numeric_limits<uint32_t>::max()), diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp index 04444647b5d..8890a6cfdda 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp @@ -212,11 +212,10 @@ MyDocumentStore::~MyDocumentStore() = default; struct MyDocumentRetriever : public DocumentRetrieverBaseForTest { std::shared_ptr<const DocumentTypeRepo> repo; const MyDocumentStore& store; - MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in) + MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in) noexcept : repo(std::move(repo_in)), store(store_in) - { - } + {} const document::DocumentTypeRepo& getDocumentTypeRepo() const override { return *repo; } void getBucketMetaData(const storage::spi::Bucket&, DocumentMetaData::Vector&) const override { abort(); } DocumentMetaData getDocumentMetaData(const DocumentId&) const override { abort(); } diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index 70b2100521f..63c7a873eaf 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -147,7 +147,7 @@ struct MyDocumentRetriever : public DocumentRetrieverBaseForTest { MyDocumentSubDB &_subDB; - explicit MyDocumentRetriever(MyDocumentSubDB &subDB) + explicit MyDocumentRetriever(MyDocumentSubDB &subDB) noexcept : _subDB(subDB) { } diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp index 8d1276497bd..e6e71d51e47 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp @@ -171,7 +171,7 @@ struct MoveOperationFeedView : public MyMinimalFeedView { struct MoveOperationCallback : public IDestructorCallback { int &outstandingMoveOps; - MoveOperationCallback(int &outstandingMoveOps_) : outstandingMoveOps(outstandingMoveOps_) { + explicit MoveOperationCallback(int &outstandingMoveOps_) noexcept : outstandingMoveOps(outstandingMoveOps_) { ++outstandingMoveOps; } ~MoveOperationCallback() override { @@ -194,7 +194,7 @@ struct FixtureBase { documentmetastore::LidReuseDelayerConfig lidReuseDelayerConfig; typename FeedViewType::UP feedview; - FixtureBase(SubDbType subDbType = SubDbType::READY) + explicit FixtureBase(SubDbType subDbType = SubDbType::READY) : removeCount(0), putCount(0), heartbeatCount(0), diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index 9ca22bafe9a..60d96e37e15 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -2090,7 +2090,7 @@ public: size_t remove_batch_cnt; size_t remove_cnt; - MockOperationListener() + MockOperationListener() noexcept : remove_batch_cnt(0), remove_cnt(0) { diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp index 08fa1b11229..38fca35ea87 100644 --- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp +++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp @@ -361,14 +361,14 @@ public: public: typedef std::shared_ptr<SimpleStrategy> SP; - SimpleStrategy() {} + SimpleStrategy() noexcept : _targets() {} uint32_t indexOf(const IFlushTarget::SP &target) const { IFlushTarget *raw = target.get(); CachedFlushTarget *cached = dynamic_cast<CachedFlushTarget*>(raw); - if (cached != NULL) { + if (cached != nullptr) { raw = cached->getFlushTarget().get(); } WrappedFlushTarget *wrapped = dynamic_cast<WrappedFlushTarget *>(raw); diff --git a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp index 5f93f97f165..1b8be388c13 100644 --- a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp +++ b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp @@ -27,16 +27,16 @@ struct SimpleFlushTarget : public test::DummyFlushTarget const Type &type, SerialNum flushedSerial_, uint64_t approxDiskBytes_, - double replay_operation_cost_) + double replay_operation_cost_) noexcept : test::DummyFlushTarget(name, type, Component::OTHER), flushedSerial(flushedSerial_), approxDiskBytes(approxDiskBytes_), replay_operation_cost(replay_operation_cost_) {} - virtual SerialNum getFlushedSerialNum() const override { + SerialNum getFlushedSerialNum() const override { return flushedSerial; } - virtual uint64_t getApproxBytesToWriteToDisk() const override { + uint64_t getApproxBytesToWriteToDisk() const override { return approxDiskBytes; } double get_replay_operation_cost() const override { diff --git a/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp b/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp index 964cd47afa5..6c502bccce1 100644 --- a/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp +++ b/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp @@ -18,26 +18,26 @@ class MyLidSpace : public search::common::ICompactableLidSpace bool _canShrink; size_t _canFree; public: - MyLidSpace() + MyLidSpace() noexcept : _canShrink(true), _canFree(16) { } - virtual ~MyLidSpace() override {} + ~MyLidSpace() override = default; - virtual void compactLidSpace(uint32_t wantedDocLidLimit) override { + void compactLidSpace(uint32_t wantedDocLidLimit) override { (void) wantedDocLidLimit; } - virtual bool canShrinkLidSpace() const override { + bool canShrinkLidSpace() const override { return _canShrink; } - virtual size_t getEstimatedShrinkLidSpaceGain() const override { + size_t getEstimatedShrinkLidSpaceGain() const override { return _canShrink ? _canFree : 0; } - virtual void shrinkLidSpace() override { + void shrinkLidSpace() override { if (_canShrink) { _canFree = 0; _canShrink = false; @@ -62,9 +62,11 @@ struct Fixture { } - ~Fixture() { } + ~Fixture(); }; +Fixture::~Fixture() = default; + TEST_F("require that flush target returns estimated memory gain", Fixture) { auto memoryGain = f._ft->getApproxMemoryGain(); diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 22dc19167f6..30f83273bd7 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -284,7 +284,7 @@ struct MyWorld { struct MySearchHandler : ISearchHandler { Matcher::SP _matcher; - MySearchHandler(Matcher::SP matcher) : _matcher(matcher) {} + MySearchHandler(Matcher::SP matcher) noexcept : _matcher(std::move(matcher)) {} DocsumReply::UP getDocsums(const DocsumRequest &) override { return DocsumReply::UP(); diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp index 48b2a269f6b..bacdd85dcc5 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp +++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp @@ -61,7 +61,7 @@ struct MyDocumentDBReference : public MockDocumentDBReference { std::shared_ptr<MockGidToLidChangeHandler> _gidToLidChangeHandler; MyDocumentDBReference(MyGidToLidMapperFactory::SP factory_, - std::shared_ptr<MockGidToLidChangeHandler> gidToLidChangeHandler) + std::shared_ptr<MockGidToLidChangeHandler> gidToLidChangeHandler) noexcept : factory(std::move(factory_)), _gidToLidChangeHandler(std::move(gidToLidChangeHandler)) { diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp index 920472c6a01..a10d48ee7fe 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/gid_to_lid_change_handler_test.cpp @@ -39,7 +39,7 @@ class ListenerStats { uint32_t _destroyedListeners; public: - ListenerStats() + ListenerStats() noexcept : _lock(), _putChanges(0u), _removeChanges(0u), diff --git a/searchcore/src/tests/proton/reprocessing/reprocessing_runner/reprocessing_runner_test.cpp b/searchcore/src/tests/proton/reprocessing/reprocessing_runner/reprocessing_runner_test.cpp index 0053a03105f..242ad91271e 100644 --- a/searchcore/src/tests/proton/reprocessing/reprocessing_runner/reprocessing_runner_test.cpp +++ b/searchcore/src/tests/proton/reprocessing/reprocessing_runner/reprocessing_runner_test.cpp @@ -32,7 +32,7 @@ struct MyTask : public IReprocessingTask double initProgress, double middleProgress, double finalProgress, - double weight) + double weight) noexcept : _runner(runner), _initProgress(initProgress), _middleProgress(middleProgress), @@ -42,9 +42,7 @@ struct MyTask : public IReprocessingTask { } - virtual void - run() override - { + void run() override { ASSERT_EQUAL(_initProgress, _runner.getProgress()); _myProgress = 0.5; ASSERT_EQUAL(_middleProgress, _runner.getProgress()); @@ -52,9 +50,7 @@ struct MyTask : public IReprocessingTask ASSERT_EQUAL(_finalProgress, _runner.getProgress()); } - virtual Progress - getProgress() const override - { + Progress getProgress() const override { return Progress(_myProgress, _weight); } @@ -65,11 +61,7 @@ struct MyTask : public IReprocessingTask double finalProgress, double weight) { - return std::make_shared<MyTask>(runner, - initProgress, - middleProgress, - finalProgress, - weight); + return std::make_shared<MyTask>(runner, initProgress, middleProgress, finalProgress, weight); } }; @@ -77,16 +69,8 @@ TEST_F("require that progress is calculated when tasks are executed", Fixture) { TaskList tasks; EXPECT_EQUAL(0.0, f._runner.getProgress()); - tasks.push_back(MyTask::create(f._runner, - 0.0, - 0.1, - 0.2, - 1.0)); - tasks.push_back(MyTask::create(f._runner, - 0.2, - 0.6, - 1.0, - 4.0)); + tasks.push_back(MyTask::create(f._runner, 0.0, 0.1, 0.2, 1.0)); + tasks.push_back(MyTask::create(f._runner, 0.2, 0.6, 1.0, 4.0)); f._runner.addTasks(tasks); tasks.clear(); EXPECT_EQUAL(0.0, f._runner.getProgress()); @@ -99,11 +83,7 @@ TEST_F("require that runner can be reset", Fixture) { TaskList tasks; EXPECT_EQUAL(0.0, f._runner.getProgress()); - tasks.push_back(MyTask::create(f._runner, - 0.0, - 0.5, - 1.0, - 1.0)); + tasks.push_back(MyTask::create(f._runner, 0.0, 0.5, 1.0, 1.0)); f._runner.addTasks(tasks); tasks.clear(); EXPECT_EQUAL(0.0, f._runner.getProgress()); @@ -111,21 +91,13 @@ TEST_F("require that runner can be reset", Fixture) EXPECT_EQUAL(1.0, f._runner.getProgress()); f._runner.reset(); EXPECT_EQUAL(0.0, f._runner.getProgress()); - tasks.push_back(MyTask::create(f._runner, - 0.0, - 0.5, - 1.0, - 1.0)); + tasks.push_back(MyTask::create(f._runner, 0.0, 0.5, 1.0, 1.0)); f._runner.addTasks(tasks); tasks.clear(); EXPECT_EQUAL(0.0, f._runner.getProgress()); f._runner.reset(); EXPECT_EQUAL(0.0, f._runner.getProgress()); - tasks.push_back(MyTask::create(f._runner, - 0.0, - 0.5, - 1.0, - 4.0)); + tasks.push_back(MyTask::create(f._runner, 0.0, 0.5, 1.0, 4.0)); f._runner.addTasks(tasks); tasks.clear(); EXPECT_EQUAL(0.0, f._runner.getProgress()); diff --git a/searchcore/src/tests/proton/server/feedstates_test.cpp b/searchcore/src/tests/proton/server/feedstates_test.cpp index 42d88328d14..59e504de6ce 100644 --- a/searchcore/src/tests/proton/server/feedstates_test.cpp +++ b/searchcore/src/tests/proton/server/feedstates_test.cpp @@ -124,7 +124,7 @@ TEST_F("require that replay progress is tracked", Fixture) { RemoveOperationContext opCtx(10); TlsReplayProgress progress("test", 5, 15); - PacketWrapper::SP wrap(new PacketWrapper(*opCtx.packet, &progress)); + auto wrap = std::make_shared<PacketWrapper>(*opCtx.packet, &progress); ForegroundThreadExecutor executor; f.state.receive(wrap, executor); diff --git a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp index 7f650847183..305f5d8c9ba 100644 --- a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp +++ b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp @@ -22,19 +22,13 @@ typedef IFlushTarget::DiskGain DiskGain; class MyFlushHandler : public IFlushHandler { public: - MyFlushHandler(const vespalib::string &name) : IFlushHandler(name) {} - // Implements IFlushHandler - virtual std::vector<IFlushTarget::SP> getFlushTargets() override { + MyFlushHandler(const vespalib::string &name) noexcept : IFlushHandler(name) {} + std::vector<IFlushTarget::SP> getFlushTargets() override { return std::vector<IFlushTarget::SP>(); } - virtual SerialNum getCurrentSerialNumber() const override { return 0; } - virtual void flushDone(SerialNum oldestSerial) override { (void) oldestSerial; } - - virtual void - syncTls(search::SerialNum syncTo) override - { - (void) syncTo; - } + SerialNum getCurrentSerialNumber() const override { return 0; } + void flushDone(SerialNum oldestSerial) override { (void) oldestSerial; } + void syncTls(search::SerialNum syncTo) override {(void) syncTo;} }; class MyFlushTarget : public test::DummyFlushTarget { @@ -47,7 +41,7 @@ private: public: MyFlushTarget(const vespalib::string &name, MemoryGain memoryGain, DiskGain diskGain, SerialNum flushedSerial, - system_time lastFlushTime, bool urgentFlush) : + system_time lastFlushTime, bool urgentFlush) noexcept : test::DummyFlushTarget(name), _memoryGain(memoryGain), _diskGain(diskGain), @@ -56,12 +50,11 @@ public: _urgentFlush(urgentFlush) { } - // Implements IFlushTarget - virtual MemoryGain getApproxMemoryGain() const override { return _memoryGain; } - virtual DiskGain getApproxDiskGain() const override { return _diskGain; } - virtual SerialNum getFlushedSerialNum() const override { return _flushedSerial; } - virtual system_time getLastFlushTime() const override { return _lastFlushTime; } - virtual bool needUrgentFlush() const override { return _urgentFlush; } + MemoryGain getApproxMemoryGain() const override { return _memoryGain; } + DiskGain getApproxDiskGain() const override { return _diskGain; } + SerialNum getFlushedSerialNum() const override { return _flushedSerial; } + system_time getLastFlushTime() const override { return _lastFlushTime; } + bool needUrgentFlush() const override { return _urgentFlush; } }; struct StringList : public std::vector<vespalib::string> { diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp index 5208195a968..33a5776cb8a 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp @@ -18,7 +18,7 @@ class PopulateDoneContext : public IDestructorCallback { std::shared_ptr<document::Document> _doc; public: - PopulateDoneContext(std::shared_ptr<document::Document> doc) + PopulateDoneContext(std::shared_ptr<document::Document> doc) noexcept : _doc(std::move(doc)) { } diff --git a/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp b/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp index 21b27ef6ffd..4d76018d66b 100644 --- a/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp @@ -7,12 +7,12 @@ namespace proton { -DocTypeName::DocTypeName(const search::engine::Request &request) +DocTypeName::DocTypeName(const search::engine::Request &request) noexcept : _name(request.propertiesMap.matchProperties().lookup("documentdb", "searchdoctype").get("")) {} -DocTypeName::DocTypeName(const document::DocumentType &docType) +DocTypeName::DocTypeName(const document::DocumentType &docType) noexcept : _name(docType.getName()) {} diff --git a/searchcore/src/vespa/searchcore/proton/common/doctypename.h b/searchcore/src/vespa/searchcore/proton/common/doctypename.h index 661d54ab8d4..f0fa3c72ee9 100644 --- a/searchcore/src/vespa/searchcore/proton/common/doctypename.h +++ b/searchcore/src/vespa/searchcore/proton/common/doctypename.h @@ -13,9 +13,9 @@ class DocTypeName vespalib::string _name; public: - explicit DocTypeName(const vespalib::string &name) : _name(name) { } - explicit DocTypeName(const search::engine::Request &request); - explicit DocTypeName(const document::DocumentType &docType); + explicit DocTypeName(const vespalib::string &name) noexcept : _name(name) { } + explicit DocTypeName(const search::engine::Request &request) noexcept; + explicit DocTypeName(const document::DocumentType &docType) noexcept; const vespalib::string & getName() const { return _name; } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/gid_compare.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/gid_compare.h index dd32abcab6e..c16dd8a7292 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/gid_compare.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/gid_compare.h @@ -14,7 +14,7 @@ class IGidCompare public: typedef std::shared_ptr<IGidCompare> SP; - virtual ~IGidCompare() {} + virtual ~IGidCompare() = default; virtual bool operator()(const document::GlobalId &lhs, const document::GlobalId &rhs) const = 0; @@ -30,14 +30,13 @@ private: document::GlobalId::BucketOrderCmp _comp; public: - DefaultGidCompare() + DefaultGidCompare() noexcept : IGidCompare(), _comp() { } - virtual bool operator()(const document::GlobalId &lhs, - const document::GlobalId &rhs) const override { + bool operator()(const document::GlobalId &lhs, const document::GlobalId &rhs) const override { return _comp(lhs, rhs); } }; diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h b/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h index 914de9df30c..ca23f27ed49 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h +++ b/searchcore/src/vespa/searchcore/proton/flushengine/iflushhandler.h @@ -28,7 +28,7 @@ public: * * @param name The unique name of this handler. */ - IFlushHandler(const vespalib::string &name) + IFlushHandler(const vespalib::string &name) noexcept : _name(name) { } diff --git a/searchcore/src/vespa/searchcore/proton/initializer/task_runner.h b/searchcore/src/vespa/searchcore/proton/initializer/task_runner.h index f28c46334bc..bd0d82b0b2c 100644 --- a/searchcore/src/vespa/searchcore/proton/initializer/task_runner.h +++ b/searchcore/src/vespa/searchcore/proton/initializer/task_runner.h @@ -28,7 +28,7 @@ class TaskRunner { using SP = std::shared_ptr<Context>; Context(InitializerTask::SP rootTask, vespalib::Executor &contextExecutor, - vespalib::Executor::Task::UP doneTask) + vespalib::Executor::Task::UP doneTask) noexcept : _rootTask(rootTask), _contextExecutor(contextExecutor), _doneTask(std::move(doneTask)) diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h index 96c83270735..0cff5583bbd 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h @@ -37,7 +37,7 @@ public: vespalib::steady_time doom; SearchSessionInfo(const vespalib::string &id_in, vespalib::steady_time created_in, - vespalib::steady_time doom_in) + vespalib::steady_time doom_in) noexcept : id(id_in), created(created_in), doom(doom_in) {} }; diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp index 174ba090842..a52be734c13 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp @@ -111,7 +111,7 @@ TlsMgrWriter::sync(SerialNum syncTo) class OnCommitDone : public search::IDestructorCallback { public: - OnCommitDone(Executor & executor, std::unique_ptr<Executor::Task> task) + OnCommitDone(Executor & executor, std::unique_ptr<Executor::Task> task) noexcept : _executor(executor), _task(std::move(task)) {} diff --git a/searchcore/src/vespa/searchcore/proton/server/feedstates.h b/searchcore/src/vespa/searchcore/proton/server/feedstates.h index 0c2e9109cce..3d24f4068a2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedstates.h +++ b/searchcore/src/vespa/searchcore/proton/server/feedstates.h @@ -24,7 +24,7 @@ class InitState : public FeedState { vespalib::string _doc_type_name; public: - InitState(const vespalib::string &name) + InitState(const vespalib::string &name) noexcept : FeedState(INIT), _doc_type_name(name) { @@ -73,7 +73,7 @@ class NormalState : public FeedState { FeedHandler &_handler; public: - NormalState(FeedHandler &handler) + NormalState(FeedHandler &handler) noexcept : FeedState(NORMAL), _handler(handler) { } diff --git a/searchcore/src/vespa/searchcore/proton/server/move_operation_limiter.cpp b/searchcore/src/vespa/searchcore/proton/server/move_operation_limiter.cpp index e535b05393c..c84abb373f8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/move_operation_limiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/move_operation_limiter.cpp @@ -10,7 +10,7 @@ using BlockedReason = IBlockableMaintenanceJob::BlockedReason; struct MoveOperationLimiter::Callback : public search::IDestructorCallback { MoveOperationLimiter::SP _limiter; - Callback(MoveOperationLimiter::SP limiter) : _limiter(std::move(limiter)) {} + Callback(MoveOperationLimiter::SP limiter) noexcept : _limiter(std::move(limiter)) {} virtual ~Callback() { _limiter->endOperation(); } }; diff --git a/searchcore/src/vespa/searchcore/proton/server/packetwrapper.h b/searchcore/src/vespa/searchcore/proton/server/packetwrapper.h index c36652ec847..6f132604662 100644 --- a/searchcore/src/vespa/searchcore/proton/server/packetwrapper.h +++ b/searchcore/src/vespa/searchcore/proton/server/packetwrapper.h @@ -20,8 +20,7 @@ struct PacketWrapper { search::transactionlog::client::RPC::Result result; vespalib::Gate gate; - PacketWrapper(const search::transactionlog::Packet &p, - TlsReplayProgress *progress_) + PacketWrapper(const search::transactionlog::Packet &p, TlsReplayProgress *progress_) noexcept : packet(p), progress(progress_), result(search::transactionlog::client::RPC::ERROR), diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp index c724e1065e9..62ffdb3e5a8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp @@ -19,7 +19,7 @@ namespace { struct Pair { string key; string value; - Pair(const string &k, const string &v) + Pair(const string &k, const string &v) noexcept : key(k), value(v) { diff --git a/searchcore/src/vespa/searchcore/proton/test/document_meta_store_observer.h b/searchcore/src/vespa/searchcore/proton/test/document_meta_store_observer.h index 66cc5ed0fea..a6ff6d86d0d 100644 --- a/searchcore/src/vespa/searchcore/proton/test/document_meta_store_observer.h +++ b/searchcore/src/vespa/searchcore/proton/test/document_meta_store_observer.h @@ -15,38 +15,36 @@ struct DocumentMetaStoreObserver : public IDocumentMetaStore DocId _compactLidSpaceLidLimit; uint32_t _holdUnblockShrinkLidSpaceCnt; - DocumentMetaStoreObserver(IDocumentMetaStore &store) + DocumentMetaStoreObserver(IDocumentMetaStore &store) noexcept : _store(store), _removeCompleteCnt(0), _removeCompleteLid(0), _compactLidSpaceLidLimit(0), _holdUnblockShrinkLidSpaceCnt(0) - { - } + {} /** * Implements search::IDocumentMetaStore **/ - virtual bool getGid(DocId lid, GlobalId &gid) const override { + bool getGid(DocId lid, GlobalId &gid) const override { return _store.getGid(lid, gid); } - virtual bool getGidEvenIfMoved(DocId lid, GlobalId &gid) const override { + bool getGidEvenIfMoved(DocId lid, GlobalId &gid) const override { return _store.getGidEvenIfMoved(lid, gid); } - virtual bool getLid(const GlobalId &gid, DocId &lid) const override { + bool getLid(const GlobalId &gid, DocId &lid) const override { return _store.getLid(gid, lid); } - virtual search::DocumentMetaData getMetaData(const GlobalId &gid) const override { + search::DocumentMetaData getMetaData(const GlobalId &gid) const override { return _store.getMetaData(gid); } - virtual void getMetaData(const BucketId &bucketId, - search::DocumentMetaData::Vector &result) const override { + void getMetaData(const BucketId &bucketId, search::DocumentMetaData::Vector &result) const override { _store.getMetaData(bucketId, result); } - virtual search::LidUsageStats getLidUsageStats() const override { + search::LidUsageStats getLidUsageStats() const override { return _store.getLidUsageStats(); } - virtual search::queryeval::Blueprint::UP createWhiteListBlueprint() const override { + search::queryeval::Blueprint::UP createWhiteListBlueprint() const override { return _store.createWhiteListBlueprint(); } uint64_t getCurrentGeneration() const override { @@ -57,40 +55,39 @@ struct DocumentMetaStoreObserver : public IDocumentMetaStore /** * Implements documentmetastore::IStore. */ - virtual Result inspectExisting(const GlobalId &gid, uint64_t prepare_serial_num) override { + Result inspectExisting(const GlobalId &gid, uint64_t prepare_serial_num) override { return _store.inspectExisting(gid, prepare_serial_num); } - virtual Result inspect(const GlobalId &gid, uint64_t prepare_serial_num) override { + Result inspect(const GlobalId &gid, uint64_t prepare_serial_num) override { return _store.inspect(gid, prepare_serial_num); } - virtual Result put(const GlobalId &gid, - const BucketId &bucketId, - const Timestamp ×tamp, - uint32_t docSize, - DocId lid, - uint64_t prepare_serial_num) override { + Result put(const GlobalId &gid, + const BucketId &bucketId, + const Timestamp ×tamp, + uint32_t docSize, + DocId lid, + uint64_t prepare_serial_num) override + { return _store.put(gid, bucketId, timestamp, docSize, lid, prepare_serial_num); } - virtual bool updateMetaData(DocId lid, - const BucketId &bucketId, - const Timestamp ×tamp) override { + bool updateMetaData(DocId lid, const BucketId &bucketId, const Timestamp ×tamp) override { return _store.updateMetaData(lid, bucketId, timestamp); } - virtual bool remove(DocId lid, uint64_t prepare_serial_num) override { + bool remove(DocId lid, uint64_t prepare_serial_num) override { return _store.remove(lid, prepare_serial_num); } - virtual void removeComplete(DocId lid) override { + void removeComplete(DocId lid) override { ++_removeCompleteCnt; _removeCompleteLid = lid; _store.removeComplete(lid); } - virtual void move(DocId fromLid, DocId toLid, uint64_t prepare_serial_num) override { + void move(DocId fromLid, DocId toLid, uint64_t prepare_serial_num) override { _store.move(fromLid, toLid, prepare_serial_num); } - virtual bool validLid(DocId lid) const override { + bool validLid(DocId lid) const override { return _store.validLid(lid); } - virtual void removeBatch(const std::vector<DocId> &lidsToRemove, + void removeBatch(const std::vector<DocId> &lidsToRemove, const DocId docIdLimit) override { _store.removeBatch(lidsToRemove, docIdLimit); } diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_flush_handler.h b/searchcore/src/vespa/searchcore/proton/test/dummy_flush_handler.h index 53fa8a9c3fb..af2f4c63443 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_flush_handler.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_flush_handler.h @@ -3,37 +3,32 @@ #include <vespa/searchcore/proton/flushengine/iflushhandler.h> -namespace proton { - -namespace test { +namespace proton::test { /** * Default implementation used for testing. */ struct DummyFlushHandler : public IFlushHandler { - DummyFlushHandler(const vespalib::string &name) + DummyFlushHandler(const vespalib::string &name) noexcept : IFlushHandler(name) {} - // Implements IFlushHandler - virtual std::vector<IFlushTarget::SP> getFlushTargets() override { + std::vector<IFlushTarget::SP> getFlushTargets() override { return std::vector<IFlushTarget::SP>(); } - virtual SerialNum getCurrentSerialNumber() const override { + SerialNum getCurrentSerialNumber() const override { return 0; } - virtual void flushDone(SerialNum oldestSerial) override { + void flushDone(SerialNum oldestSerial) override { (void) oldestSerial; } - virtual void syncTls(SerialNum syncTo) override { + void syncTls(SerialNum syncTo) override { (void) syncTo; } }; -} // namespace test - -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_flush_target.h b/searchcore/src/vespa/searchcore/proton/test/dummy_flush_target.h index 8e291126430..dd3cd49df2f 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_flush_target.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_flush_target.h @@ -3,39 +3,33 @@ #include <vespa/searchcorespi/flush/iflushtarget.h> -namespace proton { - -namespace test { +namespace proton::test { struct DummyFlushTarget : public searchcorespi::IFlushTarget { - DummyFlushTarget(const vespalib::string &name) + DummyFlushTarget(const vespalib::string &name) noexcept : searchcorespi::IFlushTarget(name) {} DummyFlushTarget(const vespalib::string &name, const Type &type, - const Component &component) + const Component &component) noexcept : searchcorespi::IFlushTarget(name, type, component) {} - // Implements searchcorespi::IFlushTarget - virtual MemoryGain getApproxMemoryGain() const override { return MemoryGain(0, 0); } - virtual DiskGain getApproxDiskGain() const override { return DiskGain(0, 0); } - virtual SerialNum getFlushedSerialNum() const override { return 0; } - virtual Time getLastFlushTime() const override { return Time(); } - virtual bool needUrgentFlush() const override { return false; } - virtual searchcorespi::FlushTask::UP initFlush(SerialNum) override { + MemoryGain getApproxMemoryGain() const override { return MemoryGain(0, 0); } + DiskGain getApproxDiskGain() const override { return DiskGain(0, 0); } + SerialNum getFlushedSerialNum() const override { return 0; } + Time getLastFlushTime() const override { return Time(); } + bool needUrgentFlush() const override { return false; } + searchcorespi::FlushTask::UP initFlush(SerialNum) override { return searchcorespi::FlushTask::UP(); } - virtual searchcorespi::FlushStats getLastFlushStats() const override { + searchcorespi::FlushStats getLastFlushStats() const override { return searchcorespi::FlushStats(); } - virtual uint64_t getApproxBytesToWriteToDisk() const override { + uint64_t getApproxBytesToWriteToDisk() const override { return 0; } }; -} // namespace test - -} // namespace proton - +} diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h index e808f721e83..f9531486e9b 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h @@ -23,7 +23,7 @@ private: std::vector<std::unique_ptr<IGidToLidChangeListener>> _listeners; public: - MockGidToLidChangeHandler() + MockGidToLidChangeHandler() noexcept : IGidToLidChangeHandler(), _adds(), _removes(), @@ -31,7 +31,7 @@ public: { } - ~MockGidToLidChangeHandler() override { } + ~MockGidToLidChangeHandler() override = default; void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override { _adds.emplace_back(listener->getDocTypeName(), listener->getName()); diff --git a/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h b/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h index 10ed19a7244..3a67333c9d5 100644 --- a/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h +++ b/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h @@ -45,8 +45,8 @@ public: template<typename T> class Gain { public: - Gain() : _before(0), _after(0) { } - Gain(T before, T after) : _before(before), _after(after) { } + Gain() noexcept : _before(0), _after(0) { } + Gain(T before, T after) noexcept : _before(before), _after(after) { } T getBefore() const { return _before; } T getAfter() const { return _after; } T gain() const { return _before - _after; } @@ -74,7 +74,7 @@ public: * * @param name The handler-wide unique name of this target. */ - IFlushTarget(const vespalib::string &name) + IFlushTarget(const vespalib::string &name) noexcept : _name(name), _type(Type::OTHER), _component(Component::OTHER) @@ -89,7 +89,7 @@ public: */ IFlushTarget(const vespalib::string &name, const Type &type, - const Component &component) + const Component &component) noexcept : _name(name), _type(type), _component(component) @@ -98,7 +98,7 @@ public: /** * Virtual destructor required for inheritance. */ - virtual ~IFlushTarget() { } + virtual ~IFlushTarget() = default; /** * Returns the handler-wide unique name of this target. diff --git a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp index 65b27dd411a..ae4b55948dc 100644 --- a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp +++ b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp @@ -62,8 +62,9 @@ struct InputInfo { std::vector<double> cmp_with; double usage_probability; double expected_usage; - InputInfo(vespalib::stringref name_in, double usage_probability_in, double expected_usage_in) - : name(name_in), cmp_with(), usage_probability(usage_probability_in), expected_usage(expected_usage_in) {} + InputInfo(vespalib::stringref name_in, double usage_probability_in, double expected_usage_in) noexcept + : name(name_in), cmp_with(), usage_probability(usage_probability_in), expected_usage(expected_usage_in) + {} double select_value() const { return cmp_with.empty() ? 0.5 : cmp_with[(cmp_with.size()-1)/2]; } diff --git a/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp b/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp index 99b22e02e2e..5976b02c5cf 100644 --- a/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp +++ b/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp @@ -11,17 +11,17 @@ using search::attribute::PostingListMerger; struct Posting { uint32_t lid; int32_t weight; - Posting(uint32_t lid_, int32_t weight_) + Posting(uint32_t lid_, int32_t weight_) noexcept : lid(lid_), weight(weight_) { } - bool operator==(const Posting &rhs) const { + bool operator==(const Posting &rhs) const noexcept { return ((lid == rhs.lid) && (weight == rhs.weight)); } - bool operator<(const Posting &rhs) const { return lid < rhs.lid; } + bool operator<(const Posting &rhs) const noexcept { return lid < rhs.lid; } }; std::ostream &operator<<(std::ostream &os, const Posting &posting) @@ -35,11 +35,11 @@ class WeightedPostingList { std::vector<Posting> _entries; public: - WeightedPostingList(std::vector<Posting> entries) + WeightedPostingList(std::vector<Posting> entries) noexcept : _entries(std::move(entries)) { } - ~WeightedPostingList() { } + ~WeightedPostingList() = default; template <typename Func> void foreach(Func func) const { @@ -67,7 +67,7 @@ struct WeightedFixture { } - ~WeightedFixture() { } + ~WeightedFixture() = default; void reserveArray(uint32_t postingsCount, size_t postingsSize) { _merger.reserveArray(postingsCount, postingsSize); } diff --git a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp index 87aea2e3e8c..7328fe2c7ff 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -140,8 +140,9 @@ struct Result { uint32_t docid; double raw_score; int32_t match_weight; - Hit(uint32_t id, double raw, int32_t match_weight_in) - : docid(id), raw_score(raw), match_weight(match_weight_in) {} + Hit(uint32_t id, double raw, int32_t match_weight_in) noexcept + : docid(id), raw_score(raw), match_weight(match_weight_in) + {} }; size_t est_hits; bool est_empty; @@ -590,7 +591,7 @@ TEST("require that attribute weighted set term works") { TEST("require that predicate query in non-predicate field yields empty.") { MyAttributeManager attribute_manager = makeAttributeManager("foo"); - PredicateQueryTerm::UP term(new PredicateQueryTerm); + auto term = std::make_unique<PredicateQueryTerm>(); SimplePredicateQuery node(std::move(term), field, 0, Weight(1)); Result result = do_search(attribute_manager, node, true); EXPECT_TRUE(result.est_empty); @@ -605,7 +606,7 @@ TEST("require that predicate query in predicate field yields results.") { const_cast<PredicateAttribute::IntervalRange *>(attr->getIntervalRangeVector())[2] = 1u; MyAttributeManager attribute_manager(attr); - PredicateQueryTerm::UP term(new PredicateQueryTerm); + auto term = std::make_unique<PredicateQueryTerm>(); SimplePredicateQuery node(std::move(term), field, 0, Weight(1)); Result result = do_search(attribute_manager, node, true); EXPECT_FALSE(result.est_empty); diff --git a/searchlib/src/tests/memoryindex/field_index_remover/field_index_remover_test.cpp b/searchlib/src/tests/memoryindex/field_index_remover/field_index_remover_test.cpp index af7ea9be481..584a8121b16 100644 --- a/searchlib/src/tests/memoryindex/field_index_remover/field_index_remover_test.cpp +++ b/searchlib/src/tests/memoryindex/field_index_remover/field_index_remover_test.cpp @@ -16,10 +16,10 @@ using namespace search::memoryindex; struct WordFieldPair { vespalib::string _word; uint32_t _fieldId; - WordFieldPair(vespalib::stringref word, uint32_t fieldId) + WordFieldPair(vespalib::stringref word, uint32_t fieldId) noexcept : _word(word), _fieldId(fieldId) {} - bool operator<(const WordFieldPair &rhs) const { + bool operator<(const WordFieldPair &rhs) const noexcept { if (_word != rhs._word) { return _word < rhs._word; } diff --git a/searchlib/src/tests/query/querybuilder_test.cpp b/searchlib/src/tests/query/querybuilder_test.cpp index 269600d26d4..5a5a5eafb2c 100644 --- a/searchlib/src/tests/query/querybuilder_test.cpp +++ b/searchlib/src/tests/query/querybuilder_test.cpp @@ -38,7 +38,7 @@ const uint32_t x_aspect = 0; const Location location(position, max_distance, x_aspect); PredicateQueryTerm::UP getPredicateQueryTerm() { - PredicateQueryTerm::UP pqt(new PredicateQueryTerm); + auto pqt = std::make_unique<PredicateQueryTerm>(); pqt->addFeature("key", "value"); pqt->addRangeFeature("key2", 42, 0xfff); return pqt; @@ -242,7 +242,7 @@ void checkQueryTreeTypes(Node *node) { EXPECT_TRUE(checkTerm(string_term, str[5], view[5], id[5], weight[5])); auto* predicateQuery = as_node<PredicateQuery>(and_node->getChildren()[5]); - PredicateQueryTerm::UP pqt(new PredicateQueryTerm); + auto pqt = std::make_unique<PredicateQueryTerm>(); EXPECT_TRUE(checkTerm(predicateQuery, getPredicateQueryTerm(), view[3], id[3], weight[3])); auto* dotProduct = as_node<DotProduct>(and_node->getChildren()[6]); diff --git a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp index 28b0d103040..3dd2ec26dea 100644 --- a/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/predicate/predicate_blueprint_test.cpp @@ -40,9 +40,9 @@ struct Fixture { Fixture() : field(42, 0), - attribute(new PredicateAttribute("f", attribute::Config(attribute::BasicType::PREDICATE))), - query(PredicateQueryTerm::UP(new PredicateQueryTerm), - "view", 0, Weight(1)) { + attribute(std::make_shared<PredicateAttribute>("f", attribute::Config(attribute::BasicType::PREDICATE))), + query(std::make_unique<PredicateQueryTerm>(),"view", 0, Weight(1)) + { query.getTerm()->addFeature("key", "value"); query.getTerm()->addRangeFeature("range_key", 42); } @@ -219,7 +219,7 @@ TEST_F("require that blueprint can set up search with subqueries", Fixture) { std::vector<Interval>{{0x0002ffff}}; f.indexDocument(doc_id, annotations); - SimplePredicateQuery query(PredicateQueryTerm::UP(new PredicateQueryTerm), + SimplePredicateQuery query(std::make_unique<PredicateQueryTerm>(), "view", 0, Weight(1)); query.getTerm()->addFeature("key", "value", 1); query.getTerm()->addFeature("key2", "value", 2); diff --git a/searchlib/src/tests/transactionlog/chunks_test.cpp b/searchlib/src/tests/transactionlog/chunks_test.cpp index 4a74dd7f5bc..a3cf9f8bd92 100644 --- a/searchlib/src/tests/transactionlog/chunks_test.cpp +++ b/searchlib/src/tests/transactionlog/chunks_test.cpp @@ -79,7 +79,7 @@ TEST("test empty commitchunk") { struct Counter : public search::IDestructorCallback { std::atomic<uint32_t> & _counter; - Counter(std::atomic<uint32_t> & counter) : _counter(counter) { _counter++; } + Counter(std::atomic<uint32_t> & counter) noexcept : _counter(counter) { _counter++; } ~Counter() override { _counter--; } }; diff --git a/searchlib/src/tests/transactionlog/translogclient_test.cpp b/searchlib/src/tests/transactionlog/translogclient_test.cpp index fffb70467a3..e097eebd42c 100644 --- a/searchlib/src/tests/transactionlog/translogclient_test.cpp +++ b/searchlib/src/tests/transactionlog/translogclient_test.cpp @@ -311,7 +311,7 @@ using Counter = std::atomic<size_t>; class CountDone : public IDestructorCallback { public: - explicit CountDone(Counter & inFlight) : _inFlight(inFlight) { ++_inFlight; } + explicit CountDone(Counter & inFlight) noexcept : _inFlight(inFlight) { ++_inFlight; } ~CountDone() override { --_inFlight; } private: Counter & _inFlight; diff --git a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h index a889120f8df..1cd07cf4e23 100644 --- a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h +++ b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.h @@ -8,11 +8,8 @@ #include <memory> #include <mutex> -namespace search { - -class BitVector; - -namespace attribute { +namespace search { class BitVector; } +namespace search::attribute { /** * Class that caches posting lists (as bit vectors) for a set of search terms. @@ -31,7 +28,7 @@ public: ReadGuardUP dmsReadGuard; BitVectorSP bitVector; uint32_t docIdLimit; - Entry(ReadGuardUP dmsReadGuard_, BitVectorSP bitVector_, uint32_t docIdLimit_) + Entry(ReadGuardUP dmsReadGuard_, BitVectorSP bitVector_, uint32_t docIdLimit_) noexcept : dmsReadGuard(std::move(dmsReadGuard_)), bitVector(std::move(bitVector_)), docIdLimit(docIdLimit_) {} }; @@ -52,4 +49,3 @@ public: }; } -} diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp index bc0d965bcc1..9c40de26db6 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp @@ -93,7 +93,7 @@ struct WeightedRef { EntryRef revMapIdx; int32_t weight; - WeightedRef(EntryRef revMapIdx_, int32_t weight_) + WeightedRef(EntryRef revMapIdx_, int32_t weight_) noexcept : revMapIdx(revMapIdx_), weight(weight_) { @@ -118,11 +118,11 @@ class ReverseMappingBitVector const ReverseMapping &_reverseMapping; EntryRef _revMapIdx; public: - ReverseMappingBitVector(const ReverseMapping &reverseMapping, EntryRef revMapIdx) + ReverseMappingBitVector(const ReverseMapping &reverseMapping, EntryRef revMapIdx) noexcept : _reverseMapping(reverseMapping), _revMapIdx(revMapIdx) {} - ~ReverseMappingBitVector() { } + ~ReverseMappingBitVector() = default; template <typename Func> void foreach_key(Func func) const { diff --git a/searchlib/src/vespa/searchlib/attribute/interlock.h b/searchlib/src/vespa/searchlib/attribute/interlock.h index cf9298686c3..30efeaf32fd 100644 --- a/searchlib/src/vespa/searchlib/attribute/interlock.h +++ b/searchlib/src/vespa/searchlib/attribute/interlock.h @@ -4,11 +4,7 @@ #include <mutex> -namespace search -{ - -namespace attribute -{ +namespace search::attribute { class InterlockGuard; @@ -35,7 +31,7 @@ class Interlock { std::mutex _mutex; friend class InterlockGuard; public: - Interlock() + Interlock() noexcept : _mutex() { } @@ -60,6 +56,4 @@ public: }; -} - -} +}
\ No newline at end of file diff --git a/searchlib/src/vespa/searchlib/attribute/multivalue.h b/searchlib/src/vespa/searchlib/attribute/multivalue.h index c59f975e00a..54c10bdc7cf 100644 --- a/searchlib/src/vespa/searchlib/attribute/multivalue.h +++ b/searchlib/src/vespa/searchlib/attribute/multivalue.h @@ -10,12 +10,9 @@ template <typename T> class Value { public: typedef T ValueType; - Value() - : _v() - { - } - Value(T v) : _v(v) { } - Value(T v, int32_t w) : _v(v) { (void) w; } + Value() noexcept : _v() {} + Value(T v) noexcept : _v(v) { } + Value(T v, int32_t w) noexcept : _v(v) { (void) w; } T value() const { return _v; } operator T () const { return _v; } operator T & () { return _v; } @@ -36,8 +33,8 @@ template <typename T> class WeightedValue { public: typedef T ValueType; - WeightedValue() : _v(), _w(1) { } - WeightedValue(T v, int32_t w) : _v(v), _w(w) { } + WeightedValue() noexcept : _v(), _w(1) { } + WeightedValue(T v, int32_t w) noexcept : _v(v), _w(w) { } T value() const { return _v; } operator T () const { return _v; } operator T & () { return _v; } diff --git a/searchlib/src/vespa/searchlib/common/gatecallback.h b/searchlib/src/vespa/searchlib/common/gatecallback.h index 1e85d796089..b6e7690f820 100644 --- a/searchlib/src/vespa/searchlib/common/gatecallback.h +++ b/searchlib/src/vespa/searchlib/common/gatecallback.h @@ -9,7 +9,7 @@ namespace search { class GateCallback : public IDestructorCallback { public: - GateCallback(vespalib::Gate & gate) : _gate(gate) {} + GateCallback(vespalib::Gate & gate) noexcept : _gate(gate) {} ~GateCallback() override; private: vespalib::Gate & _gate; @@ -17,7 +17,7 @@ private: class IgnoreCallback : public IDestructorCallback { public: - IgnoreCallback() { } + IgnoreCallback() noexcept { } ~IgnoreCallback() override = default; }; diff --git a/searchlib/src/vespa/searchlib/common/lid_usage_stats.h b/searchlib/src/vespa/searchlib/common/lid_usage_stats.h index 1dd3881892f..97e16ffe768 100644 --- a/searchlib/src/vespa/searchlib/common/lid_usage_stats.h +++ b/searchlib/src/vespa/searchlib/common/lid_usage_stats.h @@ -20,7 +20,7 @@ private: uint32_t _highestUsedLid; public: - LidUsageStats() + LidUsageStats() noexcept : _lidLimit(0), _usedLids(0), _lowestFreeLid(0), @@ -30,7 +30,7 @@ public: LidUsageStats(uint32_t lidLimit, uint32_t usedLids, uint32_t lowestFreeLid, - uint32_t highestUsedLid) + uint32_t highestUsedLid) noexcept : _lidLimit(lidLimit), _usedLids(usedLids), _lowestFreeLid(lowestFreeLid), diff --git a/searchlib/src/vespa/searchlib/common/rankedhit.h b/searchlib/src/vespa/searchlib/common/rankedhit.h index 635f6e350a5..8a0efb4ce3c 100644 --- a/searchlib/src/vespa/searchlib/common/rankedhit.h +++ b/searchlib/src/vespa/searchlib/common/rankedhit.h @@ -9,8 +9,8 @@ namespace search { struct RankedHit { - RankedHit() : _docId(0), _rankValue(zero_rank_value) { } - RankedHit(unsigned int docId, HitRank rank = zero_rank_value) : _docId(docId), _rankValue(rank) { } + RankedHit() noexcept : _docId(0), _rankValue(zero_rank_value) { } + RankedHit(unsigned int docId, HitRank rank = zero_rank_value) noexcept : _docId(docId), _rankValue(rank) { } unsigned int getDocId() const { return _docId & 0x7fffffff; } bool hasMore() const { return _docId & 0x80000000; } HitRank getRank() const { return _rankValue; } @@ -21,13 +21,13 @@ struct RankedHit { class RankedHitIterator { public: - RankedHitIterator(const RankedHit * h, size_t sz) : _h(h), _sz(sz), _pos(0) { } - bool hasNext() const { return _pos < _sz; } - uint32_t next() { return _h[_pos++].getDocId(); } + RankedHitIterator(const RankedHit * h, size_t sz) noexcept : _h(h), _sz(sz), _pos(0) { } + bool hasNext() const noexcept { return _pos < _sz; } + uint32_t next() noexcept { return _h[_pos++].getDocId(); } private: const RankedHit *_h; - const size_t _sz; - size_t _pos; + const size_t _sz; + size_t _pos; }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h b/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h index 27bbe751532..00f0d4b29f5 100644 --- a/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h +++ b/searchlib/src/vespa/searchlib/common/scheduletaskcallback.h @@ -4,8 +4,7 @@ #include "idestructorcallback.h" #include <vespa/vespalib/util/executor.h> -namespace search -{ +namespace search { /** * Class that schedules a task when instance is destroyed. Typically a @@ -20,12 +19,11 @@ class ScheduleTaskCallback : public IDestructorCallback vespalib::Executor::Task::UP _task; public: ScheduleTaskCallback(vespalib::Executor &executor, - vespalib::Executor::Task::UP task) + vespalib::Executor::Task::UP task) noexcept : _executor(executor), _task(std::move(task)) - { - } - virtual ~ScheduleTaskCallback() { + {} + ~ScheduleTaskCallback() override { _executor.execute(std::move(_task)); } }; diff --git a/searchlib/src/vespa/searchlib/common/tunefileinfo.h b/searchlib/src/vespa/searchlib/common/tunefileinfo.h index bcd6765845b..e27290d35de 100644 --- a/searchlib/src/vespa/searchlib/common/tunefileinfo.h +++ b/searchlib/src/vespa/searchlib/common/tunefileinfo.h @@ -19,7 +19,7 @@ private: TuneControl _tuneControl; public: - TuneFileSeqRead() : _tuneControl(NORMAL) { } + TuneFileSeqRead() noexcept : _tuneControl(NORMAL) { } void setWantDirectIO() { _tuneControl = DIRECTIO; } bool getWantDirectIO() const { return _tuneControl == DIRECTIO; } @@ -62,7 +62,7 @@ private: TuneControl _tuneControl; public: - TuneFileSeqWrite() : _tuneControl(NORMAL) { } + TuneFileSeqWrite() noexcept : _tuneControl(NORMAL) { } void setWantDirectIO() { _tuneControl = DIRECTIO; } bool getWantDirectIO() const { return _tuneControl == DIRECTIO; } bool getWantSyncWrites() const { return _tuneControl == OSYNC; } @@ -99,7 +99,7 @@ private: int _mmapFlags; int _advise; public: - TuneFileRandRead() + TuneFileRandRead() noexcept : _tuneControl(NORMAL), _mmapFlags(0), _advise(0) @@ -139,9 +139,9 @@ public: TuneFileSeqRead _read; TuneFileSeqWrite _write; - TuneFileIndexing() : _read(), _write() {} + TuneFileIndexing() noexcept : _read(), _write() {} - TuneFileIndexing(const TuneFileSeqRead &r, const TuneFileSeqWrite &w) : _read(r), _write(w) { } + TuneFileIndexing(const TuneFileSeqRead &r, const TuneFileSeqWrite &w) noexcept : _read(r), _write(w) { } bool operator==(const TuneFileIndexing &rhs) const { return _read == rhs._read && _write == rhs._write; @@ -161,8 +161,8 @@ class TuneFileSearch public: TuneFileRandRead _read; - TuneFileSearch() : _read() { } - TuneFileSearch(const TuneFileRandRead &r) : _read(r) { } + TuneFileSearch() noexcept : _read() { } + TuneFileSearch(const TuneFileRandRead &r) noexcept : _read(r) { } bool operator==(const TuneFileSearch &rhs) const { return _read == rhs._read; } bool operator!=(const TuneFileSearch &rhs) const { return _read != rhs._read; } }; @@ -178,7 +178,7 @@ public: TuneFileIndexing _indexing; TuneFileSearch _search; - TuneFileIndexManager() : _indexing(), _search() { } + TuneFileIndexManager() noexcept : _indexing(), _search() { } bool operator==(const TuneFileIndexManager &rhs) const { return _indexing == rhs._indexing && _search == rhs._search; @@ -198,7 +198,7 @@ class TuneFileAttributes public: TuneFileSeqWrite _write; - TuneFileAttributes() : _write() { } + TuneFileAttributes() noexcept : _write() { } bool operator==(const TuneFileAttributes &rhs) const { return _write == rhs._write; @@ -220,7 +220,7 @@ public: TuneFileSeqWrite _write; TuneFileRandRead _randRead; - TuneFileSummary() : _seqRead(), _write(), _randRead() { } + TuneFileSummary() noexcept : _seqRead(), _write(), _randRead() { } bool operator==(const TuneFileSummary &rhs) const { return _seqRead == rhs._seqRead && @@ -248,7 +248,7 @@ public: TuneFileAttributes _attr; TuneFileSummary _summary; - TuneFileDocumentDB() : _index(), _attr(), _summary() { } + TuneFileDocumentDB() noexcept : _index(), _attr(), _summary() { } bool operator==(const TuneFileDocumentDB &rhs) const { return _index == rhs._index && diff --git a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h index e9b1efa5c7d..4e71a8356c0 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h +++ b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h @@ -24,7 +24,7 @@ public: uint32_t _field_length; uint32_t _num_occs; uint32_t _features_size; - DocIdAndFeatureSize(uint32_t doc_id, uint32_t field_length, uint32_t num_occs, uint32_t features_size) + DocIdAndFeatureSize(uint32_t doc_id, uint32_t field_length, uint32_t num_occs, uint32_t features_size) noexcept : _doc_id(doc_id), _field_length(field_length), _num_occs(num_occs), diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.h b/searchlib/src/vespa/searchlib/docstore/filechunk.h index b68db801d60..6839423d6db 100644 --- a/searchlib/src/vespa/searchlib/docstore/filechunk.h +++ b/searchlib/src/vespa/searchlib/docstore/filechunk.h @@ -76,7 +76,7 @@ public: using LockGuard = vespalib::LockGuard; class NameId { public: - explicit NameId(size_t id) : _id(id) { } + explicit NameId(size_t id) noexcept : _id(id) { } uint64_t getId() const { return _id; } vespalib::string createName(const vespalib::string &baseName) const; bool operator == (const NameId & rhs) const { return _id == rhs._id; } @@ -90,7 +90,7 @@ public: }; class FileId { public: - explicit FileId(uint32_t id) : _id(id) { } + explicit FileId(uint32_t id) noexcept : _id(id) { } uint32_t getId() const { return _id; } bool operator != (const FileId & rhs) const { return _id != rhs._id; } bool operator == (const FileId & rhs) const { return _id == rhs._id; } diff --git a/searchlib/src/vespa/searchlib/docstore/lid_info.h b/searchlib/src/vespa/searchlib/docstore/lid_info.h index 10ddd868c41..8444a9e3575 100644 --- a/searchlib/src/vespa/searchlib/docstore/lid_info.h +++ b/searchlib/src/vespa/searchlib/docstore/lid_info.h @@ -11,8 +11,8 @@ namespace search { class LidInfo { public: - LidInfo() : _value() { } - LidInfo(uint64_t rep) { _value.r = rep; } + LidInfo() noexcept : _value() { } + LidInfo(uint64_t rep) noexcept { _value.r = rep; } LidInfo(uint32_t fileId, uint32_t chunkId, uint32_t size); uint32_t getFileId() const { return _value.v.fileId; } uint32_t getChunkId() const { return _value.v.chunkId; } @@ -57,7 +57,7 @@ private: class LidInfoWithLid : public LidInfo { public: - LidInfoWithLid(LidInfo lidInfo, uint32_t lid) : LidInfo(lidInfo), _lid(lid) { } + LidInfoWithLid(LidInfo lidInfo, uint32_t lid) noexcept : LidInfo(lidInfo), _lid(lid) { } uint32_t getLid() const { return _lid; } private: uint32_t _lid; diff --git a/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp b/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp index 5e595d0bb14..d7711b61d78 100644 --- a/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp +++ b/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp @@ -12,7 +12,7 @@ using document::BucketId; using vespalib::makeTask; using vespalib::makeClosure; -StoreByBucket::StoreByBucket(MemoryDataStore & backingMemory, Executor & executor, const CompressionConfig & compression) +StoreByBucket::StoreByBucket(MemoryDataStore & backingMemory, Executor & executor, const CompressionConfig & compression) noexcept : _chunkSerial(0), _current(), _where(), diff --git a/searchlib/src/vespa/searchlib/docstore/storebybucket.h b/searchlib/src/vespa/searchlib/docstore/storebybucket.h index 8be0610b588..1365dcb4416 100644 --- a/searchlib/src/vespa/searchlib/docstore/storebybucket.h +++ b/searchlib/src/vespa/searchlib/docstore/storebybucket.h @@ -24,9 +24,12 @@ class StoreByBucket using ConstBufferRef = vespalib::ConstBufferRef; using CompressionConfig = vespalib::compression::CompressionConfig; public: - StoreByBucket(vespalib::MemoryDataStore & backingMemory, const CompressionConfig & compression); - StoreByBucket(MemoryDataStore & backingMemory, Executor & executor, const CompressionConfig & compression); - StoreByBucket(StoreByBucket &&) = default; + StoreByBucket(MemoryDataStore & backingMemory, Executor & executor, const CompressionConfig & compression) noexcept; + //TODO Putting the below move constructor into cpp file fails for some unknown reason. Needs to be resolved. + StoreByBucket(StoreByBucket &&) noexcept = default; + StoreByBucket(const StoreByBucket &) = delete; + StoreByBucket & operator=(StoreByBucket &&) noexcept = delete; + StoreByBucket & operator = (const StoreByBucket &) = delete; ~StoreByBucket(); class IWrite { public: @@ -52,10 +55,10 @@ private: void closeChunk(Chunk::UP chunk); struct Index { using BucketId=document::BucketId; - Index(BucketId bucketId, uint32_t id, uint32_t chunkId, uint32_t entry) : + Index(BucketId bucketId, uint32_t id, uint32_t chunkId, uint32_t entry) noexcept : _bucketId(bucketId), _id(id), _chunkId(chunkId), _lid(entry) { } - bool operator < (const Index & b) const { + bool operator < (const Index & b) const noexcept { return BucketId::bucketIdToKey(_bucketId.getRawId()) < BucketId::bucketIdToKey(b._bucketId.getRawId()); } BucketId _bucketId; diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.h b/searchlib/src/vespa/searchlib/docstore/visitcache.h index 8a06794ee35..25a7be5ee6c 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.h +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.h @@ -40,7 +40,7 @@ class BlobSet { public: class LidPosition { public: - LidPosition(uint32_t lid, uint32_t offset, uint32_t size) : _lid(lid), _offset(offset), _size(size) { } + LidPosition(uint32_t lid, uint32_t offset, uint32_t size) noexcept : _lid(lid), _offset(offset), _size(size) { } uint32_t lid() const { return _lid; } uint32_t offset() const { return _offset; } uint32_t size() const { return _size; } diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp index 3517595d00a..beece528795 100644 --- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp @@ -204,7 +204,7 @@ seek_past(LidInfoWithLidV::const_iterator begin, LidInfoWithLidV::const_iterator } struct LidAndBuffer { - LidAndBuffer(uint32_t lid, uint32_t sz, vespalib::alloc::Alloc buf) : _lid(lid), _size(sz), _buf(std::move(buf)) {} + LidAndBuffer(uint32_t lid, uint32_t sz, vespalib::alloc::Alloc buf) noexcept : _lid(lid), _size(sz), _buf(std::move(buf)) {} uint32_t _lid; uint32_t _size; vespalib::alloc::Alloc _buf; diff --git a/searchlib/src/vespa/searchlib/engine/docsumreply.h b/searchlib/src/vespa/searchlib/engine/docsumreply.h index 37431030253..0150b1eda3d 100644 --- a/searchlib/src/vespa/searchlib/engine/docsumreply.h +++ b/searchlib/src/vespa/searchlib/engine/docsumreply.h @@ -22,9 +22,9 @@ struct DocsumReply document::GlobalId gid; Blob data; - Docsum() : docid(0), gid(), data(0) {} - Docsum(document::GlobalId gid_) : docid(0), gid(gid_), data(0) { } - Docsum(document::GlobalId gid_, const char *buf, uint32_t len) : docid(0), gid(gid_), data(len) { + Docsum() noexcept : docid(0), gid(), data(0) {} + Docsum(document::GlobalId gid_) noexcept : docid(0), gid(gid_), data(0) { } + Docsum(document::GlobalId gid_, const char *buf, uint32_t len) noexcept : docid(0), gid(gid_), data(len) { memcpy(data.str(), buf, len); } Docsum & setData(const char *buf, uint32_t len) { diff --git a/searchlib/src/vespa/searchlib/engine/docsumrequest.h b/searchlib/src/vespa/searchlib/engine/docsumrequest.h index 8aa8d036b73..8fe5aa6f465 100644 --- a/searchlib/src/vespa/searchlib/engine/docsumrequest.h +++ b/searchlib/src/vespa/searchlib/engine/docsumrequest.h @@ -23,8 +23,8 @@ public: class Hit { public: - Hit() : gid(), docid(0), path(0) {} - Hit(const document::GlobalId & gid_) : gid(gid_), docid(0), path(0) {} + Hit() noexcept : gid(), docid(0), path(0) {} + Hit(const document::GlobalId & gid_) noexcept : gid(gid_), docid(0), path(0) {} document::GlobalId gid; mutable uint32_t docid; // converted in backend diff --git a/searchlib/src/vespa/searchlib/engine/searchreply.h b/searchlib/src/vespa/searchlib/engine/searchreply.h index d9468216a90..531f94d2b6f 100644 --- a/searchlib/src/vespa/searchlib/engine/searchreply.h +++ b/searchlib/src/vespa/searchlib/engine/searchreply.h @@ -18,7 +18,7 @@ public: class Hit { public: - Hit() : gid(), metric(0), path(0), _distributionKey(0) {} + Hit() noexcept : gid(), metric(0), path(0), _distributionKey(0) {} void setDistributionKey(uint32_t key) { _distributionKey = key; } uint32_t getDistributionKey() const { return _distributionKey; } document::GlobalId gid; @@ -30,9 +30,9 @@ public: class Coverage { public: - Coverage() : Coverage(0) { } - Coverage(uint64_t active) : Coverage(active, active) { } - Coverage(uint64_t active, uint64_t covered) + Coverage() noexcept : Coverage(0) { } + Coverage(uint64_t active) noexcept : Coverage(active, active) { } + Coverage(uint64_t active, uint64_t covered) noexcept : _covered(covered), _active(active), _soonActive(active), _degradeReason(0), _nodesQueried(1), _nodesReplied(1) { } diff --git a/searchlib/src/vespa/searchlib/features/array_parser.h b/searchlib/src/vespa/searchlib/features/array_parser.h index 8bf6e9ca365..7de766efddc 100644 --- a/searchlib/src/vespa/searchlib/features/array_parser.h +++ b/searchlib/src/vespa/searchlib/features/array_parser.h @@ -29,7 +29,7 @@ public: class ValueAndIndex { public: typedef T ValueType; - ValueAndIndex(T value, uint32_t index) : _value(value), _index(index) { } + ValueAndIndex(T value, uint32_t index) noexcept : _value(value), _index(index) { } T getValue() const { return _value; } uint32_t getIndex() const { return _index; } bool operator < (const ValueAndIndex & b) const { return _index < b._index; } diff --git a/searchlib/src/vespa/searchlib/features/bm25_feature.h b/searchlib/src/vespa/searchlib/features/bm25_feature.h index 0afd14e7ac8..72dcb7e2ef7 100644 --- a/searchlib/src/vespa/searchlib/features/bm25_feature.h +++ b/searchlib/src/vespa/searchlib/features/bm25_feature.h @@ -14,7 +14,7 @@ private: fef::TermFieldHandle handle; const fef::TermFieldMatchData* tfmd; double idf_mul_k1_plus_one; - QueryTerm(fef::TermFieldHandle handle_, double inverse_doc_freq, double k1_param) + QueryTerm(fef::TermFieldHandle handle_, double inverse_doc_freq, double k1_param) noexcept : handle(handle_), tfmd(nullptr), idf_mul_k1_plus_one(inverse_doc_freq * (k1_param + 1)) diff --git a/searchlib/src/vespa/searchlib/features/fieldmatch/computer.h b/searchlib/src/vespa/searchlib/features/fieldmatch/computer.h index e4dbde1248a..a4699b17457 100644 --- a/searchlib/src/vespa/searchlib/features/fieldmatch/computer.h +++ b/searchlib/src/vespa/searchlib/features/fieldmatch/computer.h @@ -289,7 +289,7 @@ private: struct SegmentData { SegmentData() : segment(), valid(false) {} - SegmentData(SegmentStart::SP ss, bool v = false) : segment(std::move(ss)), valid(v) {} + SegmentData(SegmentStart::SP ss, bool v = false) noexcept : segment(std::move(ss)), valid(v) {} SegmentStart::SP segment; bool valid; }; diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.cpp b/searchlib/src/vespa/searchlib/fef/rank_program.cpp index 0bc85a63ceb..dd1e774607f 100644 --- a/searchlib/src/vespa/searchlib/fef/rank_program.cpp +++ b/searchlib/src/vespa/searchlib/fef/rank_program.cpp @@ -23,7 +23,7 @@ struct Override BlueprintResolver::FeatureRef ref; feature_t value; - Override(const BlueprintResolver::FeatureRef &r, feature_t v) + Override(const BlueprintResolver::FeatureRef &r, feature_t v) noexcept : ref(r), value(v) {} bool operator<(const Override &rhs) const { diff --git a/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp b/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp index 973e11fc0d2..11a5dd80b4c 100644 --- a/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp +++ b/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp @@ -24,7 +24,7 @@ TermMatchDataMerger::TermMatchDataMerger(const Inputs &allinputs, } } -TermMatchDataMerger::~TermMatchDataMerger() {} +TermMatchDataMerger::~TermMatchDataMerger() = default; void TermMatchDataMerger::merge(uint32_t docid) diff --git a/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.h b/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.h index e0addc374b2..fb129b792b8 100644 --- a/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.h +++ b/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.h @@ -6,8 +6,7 @@ #include "termfieldmatchdata.h" #include <vector> -namespace search { -namespace fef { +namespace search::fef { class TermMatchDataMerger { @@ -16,8 +15,8 @@ public: const TermFieldMatchData *matchData; double exactness; - Input() : matchData(NULL), exactness(0.0) {} - Input(const TermFieldMatchData *arg_matchData, double arg_exactness) + Input() : matchData(nullptr), exactness(0.0) {} + Input(const TermFieldMatchData *arg_matchData, double arg_exactness) noexcept : matchData(arg_matchData), exactness(arg_exactness) {} }; @@ -27,21 +26,16 @@ private: const TermFieldMatchDataArray _output; std::vector<TermFieldMatchDataPosition> _scratch; - TermMatchDataMerger(const TermMatchDataMerger &); - TermMatchDataMerger &operator=(const TermMatchDataMerger &); - - void merge(uint32_t docid, - const Inputs &in, - TermFieldMatchData &out); + void merge(uint32_t docid, const Inputs &in, TermFieldMatchData &out); public: + TermMatchDataMerger(const TermMatchDataMerger &) = delete; + TermMatchDataMerger &operator=(const TermMatchDataMerger &) = delete; - TermMatchDataMerger(const Inputs &allinputs, - const TermFieldMatchDataArray &outputs); + TermMatchDataMerger(const Inputs &allinputs, const TermFieldMatchDataArray &outputs); ~TermMatchDataMerger(); void merge(uint32_t docid); }; -} // namespace fef -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/grouping/hyperloglog.h b/searchlib/src/vespa/searchlib/grouping/hyperloglog.h index 931b832c76d..2206f4ccbe1 100644 --- a/searchlib/src/vespa/searchlib/grouping/hyperloglog.h +++ b/searchlib/src/vespa/searchlib/grouping/hyperloglog.h @@ -28,7 +28,7 @@ template <int BucketBits = 10, typename HashT = uint32_t> class ExchangerSketch : public SparseSketch<BucketBits, HashT> { typename Sketch<BucketBits, HashT>::UP &_sketch_ptr; - virtual int aggregate(HashT hash) override { + int aggregate(HashT hash) override { if (this->getSize() > SPARSE_SKETCH_LIMIT) { NormalSketch<BucketBits, HashT> *normal_sketch = new NormalSketch<BucketBits, HashT>; diff --git a/searchlib/src/vespa/searchlib/grouping/sketch.h b/searchlib/src/vespa/searchlib/grouping/sketch.h index 317c1bfef9d..c105b480a3d 100644 --- a/searchlib/src/vespa/searchlib/grouping/sketch.h +++ b/searchlib/src/vespa/searchlib/grouping/sketch.h @@ -70,21 +70,21 @@ struct SparseSketch : Sketch<BucketBits, HashT> { enum { classId = IDENTIFIABLE_CLASSID_NS(search, SparseSketch) }; struct IdentityHash { - size_t operator()(HashT hash) const { return hash; } + size_t operator()(HashT hash) const noexcept { return hash; } }; std::unordered_set<HashT, IdentityHash> hash_set; size_t getSize() const { return hash_set.size(); } - virtual int aggregate(HashT hash) override { + int aggregate(HashT hash) override { return hash_set.insert(hash).second ? 1 : 0; } - virtual uint32_t getClassId() const override { return classId; } - virtual void serialize(vespalib::Serializer &os) const override; - virtual void deserialize(vespalib::Deserializer &is) override; + uint32_t getClassId() const override { return classId; } + void serialize(vespalib::Serializer &os) const override; + void deserialize(vespalib::Deserializer &is) override; - virtual bool operator==(const SketchType &other) const override { + bool operator==(const SketchType &other) const override { const SparseSketch<BucketBits, HashT> *other_sparse = dynamic_cast<const SparseSketch<BucketBits, HashT> *>(&other); if (!other_sparse) { @@ -101,7 +101,7 @@ struct SparseSketch : Sketch<BucketBits, HashT> { return true; } - virtual void print(std::ostream &out) const override { + void print(std::ostream &out) const override { out << " (" << hash_set.size() << " elements)"; for (auto hash : hash_set) { out << " 0x" << std::hex; diff --git a/searchlib/src/vespa/searchlib/index/docidandfeatures.h b/searchlib/src/vespa/searchlib/index/docidandfeatures.h index 5372d5ef3aa..6ee80721038 100644 --- a/searchlib/src/vespa/searchlib/index/docidandfeatures.h +++ b/searchlib/src/vespa/searchlib/index/docidandfeatures.h @@ -26,14 +26,14 @@ private: uint32_t _elementLen; public: - WordDocElementFeatures() + WordDocElementFeatures() noexcept : _elementId(0u), _numOccs(0u), _weight(1), _elementLen(SEARCHLIB_FEF_UNKNOWN_FIELD_LENGTH) {} - WordDocElementFeatures(uint32_t elementId) + WordDocElementFeatures(uint32_t elementId) noexcept : _elementId(elementId), _numOccs(0u), _weight(1), @@ -42,7 +42,7 @@ public: WordDocElementFeatures(uint32_t elementId, uint32_t weight, - uint32_t elementLen) + uint32_t elementLen) noexcept : _elementId(elementId), _numOccs(0u), _weight(weight), @@ -71,11 +71,11 @@ private: uint32_t _wordPos; public: - WordDocElementWordPosFeatures() + WordDocElementWordPosFeatures() noexcept : _wordPos(0u) {} - WordDocElementWordPosFeatures(uint32_t wordPos) + WordDocElementWordPosFeatures(uint32_t wordPos) noexcept : _wordPos(wordPos) {} @@ -101,17 +101,17 @@ protected: std::vector<WordDocElementWordPosFeatures> _word_positions; // Raw data (file format specific, packed) - RawData _blob; // Feature data for (word, docid) pair + RawData _blob; // Feature data for (word, docid) pair uint32_t _bit_offset; // Offset of feature start ([0..63]) uint32_t _bit_length; // Length of features - bool _has_raw_data; + bool _has_raw_data; public: DocIdAndFeatures(); DocIdAndFeatures(const DocIdAndFeatures &); DocIdAndFeatures & operator = (const DocIdAndFeatures &); - DocIdAndFeatures(DocIdAndFeatures &&) = default; - DocIdAndFeatures & operator = (DocIdAndFeatures &&) = default; + DocIdAndFeatures(DocIdAndFeatures &&) noexcept = default; + DocIdAndFeatures & operator = (DocIdAndFeatures &&) noexcept = default; ~DocIdAndFeatures(); void clear_features() { diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index_remover.h b/searchlib/src/vespa/searchlib/memoryindex/field_index_remover.h index 36d2286cfb1..717f21528bb 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_index_remover.h +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index_remover.h @@ -21,11 +21,11 @@ private: struct WordFieldDocTuple { vespalib::datastore::EntryRef _wordRef; uint32_t _docId; - WordFieldDocTuple() : + WordFieldDocTuple() noexcept : _wordRef(0), _docId(0) { } - WordFieldDocTuple(vespalib::datastore::EntryRef wordRef, uint32_t docId) : + WordFieldDocTuple(vespalib::datastore::EntryRef wordRef, uint32_t docId) noexcept : _wordRef(wordRef), _docId(docId) { } @@ -44,12 +44,12 @@ private: CompactWordsStore _store; CompactWordsStore::Builder::UP _builder; - std::vector<WordFieldDocTuple> _wordFieldDocTuples; + std::vector<WordFieldDocTuple> _wordFieldDocTuples; const WordStore &_wordStore; public: FieldIndexRemover(const WordStore &wordStore); - ~FieldIndexRemover(); + ~FieldIndexRemover() override; void remove(uint32_t docId, IFieldIndexRemoveListener &inverter); CompactWordsStore &getStore() { return _store; } const CompactWordsStore &getStore() const { return _store; } diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h index 78a1cf6c171..3a18d0c2f8c 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h +++ b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h @@ -39,7 +39,7 @@ public: static constexpr uint32_t _elemRemoved = std::numeric_limits<uint32_t>::max(); - PosInfo() + PosInfo() noexcept : _wordNum(0), _docId(0), _elemId(0), @@ -51,7 +51,7 @@ public: PosInfo(uint32_t wordRef, uint32_t docId, uint32_t elemId, - uint32_t wordPos, uint32_t elemRef) + uint32_t wordPos, uint32_t elemRef) noexcept : _wordNum(wordRef), _docId(docId), _elemId(elemId), @@ -60,8 +60,7 @@ public: { } - PosInfo(uint32_t wordRef, - uint32_t docId) + PosInfo(uint32_t wordRef, uint32_t docId) noexcept : _wordNum(wordRef), _docId(docId), _elemId(_elemRemoved), diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index 1820fb0e969..6039a86580c 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -225,7 +225,7 @@ SimpleQueryStackDumpIterator::next() case ParseItem::ITEM_PREDICATE_QUERY: try { _curr_index_name = read_stringref(p); - _predicate_query_term.reset(new PredicateQueryTerm); + _predicate_query_term = std::make_unique<PredicateQueryTerm>(); size_t count = readCompressedPositiveInt(p); for (size_t i = 0; i < count; ++i) { diff --git a/searchlib/src/vespa/searchlib/query/streaming/hit.h b/searchlib/src/vespa/searchlib/query/streaming/hit.h index 64b71a70df9..fabaa3ad50c 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/hit.h +++ b/searchlib/src/vespa/searchlib/query/streaming/hit.h @@ -9,7 +9,7 @@ namespace search::streaming { class Hit { public: - Hit(uint32_t pos_, uint32_t context_, uint32_t elemId_, int32_t weight_) + Hit(uint32_t pos_, uint32_t context_, uint32_t elemId_, int32_t weight_) noexcept : _position(pos_ | (context_<<24)), _elemId(elemId_), _weight(weight_) diff --git a/searchlib/src/vespa/searchlib/query/tree/predicate_query_term.h b/searchlib/src/vespa/searchlib/query/tree/predicate_query_term.h index 0a92546e414..8602eb1ac57 100644 --- a/searchlib/src/vespa/searchlib/query/tree/predicate_query_term.h +++ b/searchlib/src/vespa/searchlib/query/tree/predicate_query_term.h @@ -22,7 +22,7 @@ class PredicateQueryTerm { public: Entry(const vespalib::string &key, const ValueType &value, - uint64_t sub_query_bitmap = ALL_SUB_QUERIES) + uint64_t sub_query_bitmap = ALL_SUB_QUERIES) noexcept : _key(key), _value(value), _sub_query_bitmap(sub_query_bitmap) {} vespalib::string getKey() const { return _key; } @@ -41,13 +41,7 @@ class PredicateQueryTerm { public: typedef std::unique_ptr<PredicateQueryTerm> UP; - PredicateQueryTerm() : _features(), _range_features() {} - - PredicateQueryTerm(const std::vector<Entry<vespalib::string>> &features, - const std::vector<Entry<uint64_t>> &range_features) - : _features(features), - _range_features(range_features) { - } + PredicateQueryTerm() noexcept : _features(), _range_features() {} void addFeature(const vespalib::string &key, const vespalib::string &value, uint64_t sub_query_bitmask = ALL_SUB_QUERIES) { diff --git a/searchlib/src/vespa/searchlib/query/tree/queryreplicator.h b/searchlib/src/vespa/searchlib/query/tree/queryreplicator.h index 9289df7cbe9..600249c3e1e 100644 --- a/searchlib/src/vespa/searchlib/query/tree/queryreplicator.h +++ b/searchlib/src/vespa/searchlib/query/tree/queryreplicator.h @@ -153,7 +153,7 @@ private: void visit(PredicateQuery &node) override { replicate(node, _builder.addPredicateQuery( - PredicateQueryTerm::UP(new PredicateQueryTerm(*node.getTerm())), + std::make_unique<PredicateQueryTerm>(*node.getTerm()), node.getView(), node.getId(), node.getWeight())); } diff --git a/searchlib/src/vespa/searchlib/queryeval/global_filter.h b/searchlib/src/vespa/searchlib/queryeval/global_filter.h index b30162affa7..3e57ded4898 100644 --- a/searchlib/src/vespa/searchlib/queryeval/global_filter.h +++ b/searchlib/src/vespa/searchlib/queryeval/global_filter.h @@ -21,15 +21,15 @@ private: struct ctor_tag {}; std::unique_ptr<search::BitVector> bit_vector; +public: GlobalFilter(const GlobalFilter &) = delete; GlobalFilter(GlobalFilter &&) = delete; -public: - GlobalFilter(ctor_tag, std::unique_ptr<search::BitVector> bit_vector_in) + GlobalFilter(ctor_tag, std::unique_ptr<search::BitVector> bit_vector_in) noexcept : bit_vector(std::move(bit_vector_in)) {} - GlobalFilter(ctor_tag) : bit_vector() {} + GlobalFilter(ctor_tag) noexcept : bit_vector() {} ~GlobalFilter() {} diff --git a/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.h b/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.h index f209e0f7fd8..b9812036637 100644 --- a/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.h @@ -29,7 +29,7 @@ public: SearchIterator *search; uint32_t sourceId; Child() : search(nullptr), sourceId(0) { } - Child(SearchIterator *s, uint32_t id) : search(s), sourceId(id) {} + Child(SearchIterator *s, uint32_t id) noexcept : search(s), sourceId(id) {} }; typedef std::vector<Child> Children; diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h b/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h index 071d6d99470..937e7a089df 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h @@ -41,11 +41,12 @@ struct Term { uint32_t estHits; fef::TermFieldMatchData *matchData; score_t maxScore = 0.0; // <- only used by rise wand test - Term(SearchIterator *s, int32_t w, uint32_t e, fef::TermFieldMatchData *tfmd) - : search(s), weight(w), estHits(e), matchData(tfmd) {} - Term() : Term(nullptr, 0, 0, nullptr){} - Term(SearchIterator *s, int32_t w, uint32_t e) : Term(s, w, e, nullptr) {} - Term(SearchIterator::UP s, int32_t w, uint32_t e) : Term(s.release(), w, e, nullptr) {} + Term(SearchIterator *s, int32_t w, uint32_t e, fef::TermFieldMatchData *tfmd) noexcept + : search(s), weight(w), estHits(e), matchData(tfmd) + {} + Term() noexcept : Term(nullptr, 0, 0, nullptr){} + Term(SearchIterator *s, int32_t w, uint32_t e) noexcept : Term(s, w, e, nullptr) {} + Term(SearchIterator::UP s, int32_t w, uint32_t e) noexcept : Term(s.release(), w, e, nullptr) {} }; //----------------------------------------------------------------------------- diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index 9def5a7b0a8..6488b525b7c 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -40,7 +40,7 @@ struct PairDist { uint32_t id_first; uint32_t id_second; double distance; - PairDist(uint32_t i1, uint32_t i2, double d) + PairDist(uint32_t i1, uint32_t i2, double d) noexcept : id_first(i1), id_second(i2), distance(d) {} }; diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index_utils.h b/searchlib/src/vespa/searchlib/tensor/hnsw_index_utils.h index 99266505780..d206b055071 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index_utils.h +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index_utils.h @@ -16,9 +16,9 @@ struct HnswCandidate { uint32_t docid; HnswGraph::NodeRef node_ref; double distance; - HnswCandidate(uint32_t docid_in, double distance_in) + HnswCandidate(uint32_t docid_in, double distance_in) noexcept : docid(docid_in), node_ref(), distance(distance_in) {} - HnswCandidate(uint32_t docid_in, HnswGraph::NodeRef node_ref_in, double distance_in) + HnswCandidate(uint32_t docid_in, HnswGraph::NodeRef node_ref_in, double distance_in) noexcept : docid(docid_in), node_ref(node_ref_in), distance(distance_in) {} }; diff --git a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h index 74f14cea21b..c14da0d058f 100644 --- a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h +++ b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h @@ -29,12 +29,12 @@ public: struct Neighbor { uint32_t docid; double distance; - Neighbor(uint32_t id, double dist) + Neighbor(uint32_t id, double dist) noexcept : docid(id), distance(dist) {} - Neighbor() : docid(0), distance(0.0) {} + Neighbor() noexcept : docid(0), distance(0.0) {} }; - virtual ~NearestNeighborIndex() {} + virtual ~NearestNeighborIndex() = default; virtual void add_document(uint32_t docid) = 0; /** diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h index e2fcbf444a2..0a04e1e79fd 100644 --- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h +++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.h @@ -23,7 +23,7 @@ namespace search { struct MockDocumentMetaStoreContext : public IDocumentMetaStoreContext { mutable size_t get_read_guard_cnt; - MockDocumentMetaStoreContext() : get_read_guard_cnt(0) {} + MockDocumentMetaStoreContext() noexcept : get_read_guard_cnt(0) {} IReadGuard::UP getReadGuard() const override; }; diff --git a/staging_vespalib/src/tests/metrics/mock_tick.h b/staging_vespalib/src/tests/metrics/mock_tick.h index 3f244ea6c9f..e8f621508ae 100644 --- a/staging_vespalib/src/tests/metrics/mock_tick.h +++ b/staging_vespalib/src/tests/metrics/mock_tick.h @@ -55,7 +55,7 @@ private: } public: - MockTick(TimeStamp first_value) + explicit MockTick(TimeStamp first_value) : _first_value(first_value), _lock(), _cond(), _alive(true), _prev(), _next() {} TimeStamp first() override { return _first_value; } TimeStamp next(TimeStamp prev) override { @@ -81,7 +81,7 @@ class TickProxy : public Tick { private: std::shared_ptr<Tick> _tick; public: - TickProxy(std::shared_ptr<Tick> tick) : _tick(std::move(tick)) {} + explicit TickProxy(std::shared_ptr<Tick> tick) noexcept : _tick(std::move(tick)) {} TimeStamp first() override { return _tick->first(); } TimeStamp next(TimeStamp prev) override { return _tick->next(prev); } bool alive() const override { return _tick->alive(); } diff --git a/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp b/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp index e3ff7533d58..49bc52d6239 100644 --- a/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp +++ b/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp @@ -7,7 +7,7 @@ using namespace vespalib; class A { public: - virtual ~A() { } + virtual ~A() = default; virtual void assign(const A & rhs) { (void) rhs; assert(false); } // Required by the primitive array. virtual A * clone() const { assert(false); return nullptr; } // Required for the complex array. @@ -19,7 +19,7 @@ public: class Primitive : public A { public: - Primitive(size_t v=11) : _v(v) { } + Primitive(size_t v=11) noexcept : _v(v) { } size_t value() const { return _v; } bool operator == (const A & rhs) const override { return dynamic_cast<const Primitive &>(rhs).value() == value(); @@ -38,7 +38,7 @@ private: class Complex : public A { public: - Complex(size_t v=11) : _v(v) { } + Complex(size_t v=11) noexcept : _v(v) { } size_t value() const { return _v; } bool operator == (const A & rhs) const override { return dynamic_cast<const Complex &>(rhs).value() == value(); diff --git a/staging_vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp b/staging_vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp index 2ca49105610..e75cdd09c8c 100644 --- a/staging_vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp +++ b/staging_vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp @@ -31,7 +31,7 @@ public: int _fail; int _val; - TestObj() + TestObj() noexcept : _m(), _cv(), _done(0), diff --git a/staging_vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp b/staging_vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp index a2671bb81a7..03ec64b771e 100644 --- a/staging_vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp +++ b/staging_vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp @@ -33,7 +33,7 @@ public: int _fail; int _val; - TestObj() + TestObj() noexcept : _m(), _cv(), _done(0), diff --git a/staging_vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp b/staging_vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp index df94e70f9d6..29b25cd0471 100644 --- a/staging_vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp +++ b/staging_vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp @@ -33,7 +33,7 @@ public: int _fail; int _val; - TestObj() + TestObj() noexcept : _m(), _cv(), _done(0), diff --git a/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.cpp b/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.cpp index cd7a3abb1eb..7909ec7486e 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.cpp +++ b/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.cpp @@ -1,10 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "dummy_metrics_manager.h" -namespace vespalib { -namespace metrics { +namespace vespalib::metrics { -DummyMetricsManager::~DummyMetricsManager() {} +DummyMetricsManager::~DummyMetricsManager() = default; Snapshot DummyMetricsManager::snapshot() @@ -20,5 +19,4 @@ DummyMetricsManager::totalSnapshot() return snap; } -} // namespace vespalib::metrics -} // namespace vespalib +} diff --git a/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.h b/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.h index 6aeb1137732..1536888014a 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/dummy_metrics_manager.h @@ -10,8 +10,7 @@ #include "metrics_manager.h" #include "clock.h" -namespace vespalib { -namespace metrics { +namespace vespalib::metrics { /** * Dummy manager that discards everything, use @@ -21,9 +20,9 @@ namespace metrics { class DummyMetricsManager : public MetricsManager { protected: - DummyMetricsManager() {} + DummyMetricsManager() noexcept {} public: - ~DummyMetricsManager(); + ~DummyMetricsManager() override; static std::shared_ptr<MetricsManager> create() { return std::shared_ptr<MetricsManager>(new DummyMetricsManager()); @@ -58,5 +57,4 @@ public: void sample(Gauge::Measurement) override {} }; -} // namespace vespalib::metrics -} // namespace vespalib +} diff --git a/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp b/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp index 2c34ba306ab..b1c4a128feb 100644 --- a/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp +++ b/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp @@ -46,16 +46,16 @@ class IdentifiablePtr : public CloneablePtr<T> { public: IdentifiablePtr(const T &t) : CloneablePtr<T>(t.clone()) {} - IdentifiablePtr(IdentifiablePtr &&) = default; - IdentifiablePtr & operator = (IdentifiablePtr &&) = default; + IdentifiablePtr(IdentifiablePtr &&) noexcept = default; + IdentifiablePtr & operator = (IdentifiablePtr &&) noexcept = default; IdentifiablePtr(const IdentifiablePtr &) = default; IdentifiablePtr & operator = (const IdentifiablePtr &) = default; - IdentifiablePtr(T * p=NULL) : CloneablePtr<T>(p) { } - IdentifiablePtr(std::unique_ptr<T> &&rhs) + IdentifiablePtr(T * p=NULL) noexcept : CloneablePtr<T>(p) { } + IdentifiablePtr(std::unique_ptr<T> &&rhs) noexcept : CloneablePtr<T>(std::move(rhs)) { } - IdentifiablePtr &operator=(std::unique_ptr<T> &&rhs) + IdentifiablePtr &operator=(std::unique_ptr<T> &&rhs) noexcept { CloneablePtr<T>::operator=(std::move(rhs)); return *this; diff --git a/storage/src/tests/bucketdb/lockablemaptest.cpp b/storage/src/tests/bucketdb/lockablemaptest.cpp index 709e158e531..527c0a927b4 100644 --- a/storage/src/tests/bucketdb/lockablemaptest.cpp +++ b/storage/src/tests/bucketdb/lockablemaptest.cpp @@ -148,7 +148,7 @@ namespace { template <typename Map> struct NonConstProcessor { - typename Map::Decision operator()(int key, A& a) { + typename Map::Decision operator() (int key, A& a) const noexcept { (void) key; ++a._val2; return Map::UPDATE; diff --git a/storage/src/tests/persistence/persistencetestutils.h b/storage/src/tests/persistence/persistencetestutils.h index 3d25a205017..d4cbd896d11 100644 --- a/storage/src/tests/persistence/persistencetestutils.h +++ b/storage/src/tests/persistence/persistencetestutils.h @@ -42,7 +42,7 @@ public: class NoBucketLock : public FileStorHandler::BucketLockInterface { public: - NoBucketLock(document::Bucket bucket) : _bucket(bucket) { } + NoBucketLock(document::Bucket bucket) noexcept : _bucket(bucket) { } const document::Bucket &getBucket() const override { return _bucket; } diff --git a/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h b/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h index 9b738b26994..be83970e2b7 100644 --- a/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h +++ b/storage/src/vespa/storage/bucketdb/abstract_bucket_map.h @@ -36,7 +36,7 @@ public: key_type _key; bool _locked; - LockKeeper(AbstractBucketMap& map, key_type key) + LockKeeper(AbstractBucketMap& map, key_type key) noexcept : _map(map), _key(key), _locked(true) {} void unlock() { _map.unlock(_key); _locked = false; } public: @@ -44,7 +44,7 @@ public: }; struct WrappedEntry { - WrappedEntry() + WrappedEntry() noexcept : _exists(false), _preExisted(false), _lockKeeper(), @@ -103,16 +103,16 @@ public: key_type _key; const char* _owner; - LockId() : _key(0), _owner("none - empty token") {} - LockId(key_type key, const char* owner) + LockId() noexcept : _key(0), _owner("none - empty token") {} + LockId(key_type key, const char* owner) noexcept : _key(key), _owner(owner) { assert(_owner); } - size_t hash() const { return _key; } - size_t operator%(size_t val) const { return _key % val; } - bool operator==(const LockId& id) const { return (_key == id._key); } + size_t hash() const noexcept { return _key; } + size_t operator%(size_t val) const noexcept { return _key % val; } + bool operator==(const LockId& id) const noexcept { return (_key == id._key); } operator key_type() const { return _key; } }; diff --git a/storage/src/vespa/storage/bucketdb/bucketcopy.h b/storage/src/vespa/storage/bucketdb/bucketcopy.h index 09f86ef1324..94a1e63e53e 100644 --- a/storage/src/vespa/storage/bucketdb/bucketcopy.h +++ b/storage/src/vespa/storage/bucketdb/bucketcopy.h @@ -15,12 +15,12 @@ private: public: static const int TRUSTED = 1; - BucketCopy() + BucketCopy() noexcept : _timestamp(0), _flags(0), _node(0xffff) {} BucketCopy(uint64_t timestamp, uint16_t nodeIdx, - const api::BucketInfo& info) + const api::BucketInfo& info) noexcept : _timestamp(timestamp), _info(info), _flags(0), diff --git a/storage/src/vespa/storage/distributor/distributor.cpp b/storage/src/vespa/storage/distributor/distributor.cpp index cfd8d7f1753..e577d219f1b 100644 --- a/storage/src/vespa/storage/distributor/distributor.cpp +++ b/storage/src/vespa/storage/distributor/distributor.cpp @@ -28,7 +28,7 @@ class Distributor::Status { bool _done; public: - Status(const DelegatedStatusRequest& request) + Status(const DelegatedStatusRequest& request) noexcept : _request(request), _monitor(), _done(false) diff --git a/storage/src/vespa/storage/distributor/messagetracker.h b/storage/src/vespa/storage/distributor/messagetracker.h index 75ae287d98f..11d8c36082e 100644 --- a/storage/src/vespa/storage/distributor/messagetracker.h +++ b/storage/src/vespa/storage/distributor/messagetracker.h @@ -17,7 +17,7 @@ class MessageTracker { public: class ToSend { public: - ToSend(std::shared_ptr<api::BucketCommand> msg, uint16_t target) : + ToSend(std::shared_ptr<api::BucketCommand> msg, uint16_t target) noexcept : _msg(std::move(msg)), _target(target) {}; std::shared_ptr<api::BucketCommand> _msg; diff --git a/storage/src/vespa/storage/distributor/operation_sequencer.h b/storage/src/vespa/storage/distributor/operation_sequencer.h index cf687e721a8..7a523b61e53 100644 --- a/storage/src/vespa/storage/distributor/operation_sequencer.h +++ b/storage/src/vespa/storage/distributor/operation_sequencer.h @@ -24,7 +24,7 @@ class SequencingHandle { OperationSequencer* _sequencer; document::GlobalId _gid; public: - SequencingHandle() : _sequencer(nullptr) {} + SequencingHandle() noexcept : _sequencer(nullptr) {} SequencingHandle(OperationSequencer& sequencer, const document::GlobalId& gid) : _sequencer(&sequencer), _gid(gid) diff --git a/storage/src/vespa/storage/distributor/operations/external/updateoperation.h b/storage/src/vespa/storage/distributor/operations/external/updateoperation.h index c66026f02f5..9d9bce9160b 100644 --- a/storage/src/vespa/storage/distributor/operations/external/updateoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/updateoperation.h @@ -55,7 +55,7 @@ private: class PreviousDocumentVersion { public: - PreviousDocumentVersion(document::BucketId b, const api::BucketInfo& info, uint64_t o, uint16_t node) : + PreviousDocumentVersion(document::BucketId b, const api::BucketInfo& info, uint64_t o, uint16_t node) noexcept : bucketId(b), bucketInfo(info), oldTs(o), nodeId(node) {} document::BucketId bucketId; diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergemetadata.h b/storage/src/vespa/storage/distributor/operations/idealstate/mergemetadata.h index fb84441b654..273603ca6ad 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/mergemetadata.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergemetadata.h @@ -3,26 +3,22 @@ #pragma once #include <vespa/storage/bucketdb/bucketcopy.h> -#include <cassert> -namespace storage { -namespace distributor { +namespace storage::distributor { struct MergeMetaData { uint16_t _nodeIndex; bool _sourceOnly; const BucketCopy* _copy; - MergeMetaData() : _nodeIndex(0), _sourceOnly(false), _copy(0) {} - MergeMetaData(uint16_t nodeIndex, const BucketCopy& copy) + MergeMetaData() noexcept : _nodeIndex(0), _sourceOnly(false), _copy(nullptr) {} + MergeMetaData(uint16_t nodeIndex, const BucketCopy& copy) noexcept : _nodeIndex(nodeIndex), _sourceOnly(false), _copy(©) {} bool trusted() const { - assert(_copy != 0); return _copy->trusted(); } uint32_t checksum() const { - assert(_copy != 0); return _copy->getChecksum(); } bool source_only() const noexcept { return _sourceOnly; } @@ -30,6 +26,4 @@ struct MergeMetaData { vespalib::asciistream& operator<<(vespalib::asciistream& out, const MergeMetaData& e); -} // distributor -} // storage - +} diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp index 85604299e85..0341e34d39d 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp +++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp @@ -871,7 +871,7 @@ FileStorManager::reportHtmlStatus(std::ostream& out, const framework::HttpUrlPat namespace { struct Deactivator { - StorBucketDatabase::Decision operator()(document::BucketId::Type, StorBucketDatabase::Entry& data) + StorBucketDatabase::Decision operator() (document::BucketId::Type, StorBucketDatabase::Entry& data) noexcept { data.info.setActive(false); return StorBucketDatabase::Decision::UPDATE; diff --git a/storage/src/vespa/storage/storageserver/configurable_bucket_resolver.h b/storage/src/vespa/storage/storageserver/configurable_bucket_resolver.h index 0800cc9612e..34e30aaea48 100644 --- a/storage/src/vespa/storage/storageserver/configurable_bucket_resolver.h +++ b/storage/src/vespa/storage/storageserver/configurable_bucket_resolver.h @@ -21,7 +21,7 @@ public: using BucketSpaceMapping = std::unordered_map<vespalib::string, document::BucketSpace, vespalib::hash<vespalib::string>>; const BucketSpaceMapping _type_to_space; public: - explicit ConfigurableBucketResolver(BucketSpaceMapping type_to_space) + explicit ConfigurableBucketResolver(BucketSpaceMapping type_to_space) noexcept : _type_to_space(std::move(type_to_space)) {} diff --git a/storage/src/vespa/storage/storageserver/service_layer_error_listener.h b/storage/src/vespa/storage/storageserver/service_layer_error_listener.h index 6995459e333..5dd01329ff4 100644 --- a/storage/src/vespa/storage/storageserver/service_layer_error_listener.h +++ b/storage/src/vespa/storage/storageserver/service_layer_error_listener.h @@ -23,7 +23,7 @@ class ServiceLayerErrorListener : public ProviderErrorListener { std::atomic<bool> _shutdown_initiated; public: ServiceLayerErrorListener(StorageComponent& component, - MergeThrottler& merge_throttler) + MergeThrottler& merge_throttler) noexcept : _component(component), _merge_throttler(merge_throttler), _shutdown_initiated(false) diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp index da221e312e2..f9b5e284b93 100644 --- a/storage/src/vespa/storage/storageserver/statemanager.cpp +++ b/storage/src/vespa/storage/storageserver/statemanager.cpp @@ -224,7 +224,7 @@ StateManager::removeStateListener(StateListener& listener) struct StateManager::ExternalStateLock : public NodeStateUpdater::Lock { StateManager& _manager; - explicit ExternalStateLock(StateManager& manager) : _manager(manager) {} + explicit ExternalStateLock(StateManager& manager) noexcept : _manager(manager) {} ~ExternalStateLock() override { { vespalib::MonitorGuard lock(_manager._stateLock); diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp b/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp index c3980784106..7466d5c603e 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp @@ -5,7 +5,7 @@ namespace storage::api { -BucketInfo::BucketInfo() +BucketInfo::BucketInfo() noexcept : _lastModified(0), _checksum(0), _docCount(0), @@ -17,7 +17,7 @@ BucketInfo::BucketInfo() {} BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, - uint32_t totDocSize) + uint32_t totDocSize) noexcept : _lastModified(0), _checksum(checksum), _docCount(docCount), @@ -30,7 +30,7 @@ BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, uint32_t metaCount, - uint32_t usedFileSize) + uint32_t usedFileSize) noexcept : _lastModified(0), _checksum(checksum), _docCount(docCount), @@ -44,7 +44,7 @@ BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, uint32_t metaCount, uint32_t usedFileSize, - bool ready, bool active) + bool ready, bool active) noexcept : _lastModified(0), _checksum(checksum), _docCount(docCount), @@ -58,7 +58,7 @@ BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, uint32_t metaCount, uint32_t usedFileSize, - bool ready, bool active, Timestamp lastModified) + bool ready, bool active, Timestamp lastModified) noexcept : _lastModified(lastModified), _checksum(checksum), _docCount(docCount), @@ -69,9 +69,9 @@ BucketInfo::BucketInfo(uint32_t checksum, uint32_t docCount, _active(active) {} -BucketInfo::BucketInfo(const BucketInfo &) = default; -BucketInfo & BucketInfo::operator = (const BucketInfo &) = default; -BucketInfo::~BucketInfo() {} +BucketInfo::BucketInfo(const BucketInfo &) noexcept = default; +BucketInfo & BucketInfo::operator = (const BucketInfo &) noexcept = default; +BucketInfo::~BucketInfo() = default; bool BucketInfo::operator==(const BucketInfo& info) const diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h index a80595527e2..f15d99588ca 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h @@ -31,18 +31,18 @@ class BucketInfo : public vespalib::AsciiPrintable bool _active; public: - BucketInfo(); - BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize); + BucketInfo() noexcept; + BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize) noexcept; BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, - uint32_t metaCount, uint32_t usedFileSize); + uint32_t metaCount, uint32_t usedFileSize) noexcept; BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, uint32_t metaCount, uint32_t usedFileSize, - bool ready, bool active); + bool ready, bool active) noexcept; BucketInfo(uint32_t checksum, uint32_t docCount, uint32_t totDocSize, uint32_t metaCount, uint32_t usedFileSize, - bool ready, bool active, Timestamp lastModified); - BucketInfo(const BucketInfo &); - BucketInfo & operator = (const BucketInfo &); + bool ready, bool active, Timestamp lastModified) noexcept; + BucketInfo(const BucketInfo &) noexcept; + BucketInfo & operator = (const BucketInfo &) noexcept; ~BucketInfo(); Timestamp getLastModified() const { return _lastModified; } diff --git a/storageapi/src/vespa/storageapi/defs.h b/storageapi/src/vespa/storageapi/defs.h index e5445f22870..531a1b13120 100644 --- a/storageapi/src/vespa/storageapi/defs.h +++ b/storageapi/src/vespa/storageapi/defs.h @@ -8,8 +8,7 @@ #include <cstdint> -namespace storage { -namespace api { +namespace storage:: api { typedef uint64_t Timestamp; typedef uint32_t VisitorId; @@ -17,4 +16,3 @@ typedef uint32_t VisitorId; const Timestamp MAX_TIMESTAMP = (Timestamp)-1ll; } -} diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h index 45af2296e8a..2b09967d95b 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.h +++ b/storageapi/src/vespa/storageapi/message/bucket.h @@ -104,10 +104,10 @@ public: uint16_t index; bool sourceOnly; - Node(uint16_t index_, bool sourceOnly_ = false) + Node(uint16_t index_, bool sourceOnly_ = false) noexcept : index(index_), sourceOnly(sourceOnly_) {} - bool operator==(const Node& n) const + bool operator==(const Node& n) const noexcept { return (index == n.index && sourceOnly == n.sourceOnly); } }; @@ -123,7 +123,7 @@ public: Timestamp maxTimestamp, uint32_t clusterStateVersion = 0, const std::vector<uint16_t>& chain = std::vector<uint16_t>()); - ~MergeBucketCommand(); + ~MergeBucketCommand() override; const std::vector<Node>& getNodes() const { return _nodes; } Timestamp getMaxTimestamp() const { return _maxTimestamp; } diff --git a/storageapi/src/vespa/storageapi/message/visitor.h b/storageapi/src/vespa/storageapi/message/visitor.h index 7189cc67195..67c41a0cc4d 100644 --- a/storageapi/src/vespa/storageapi/message/visitor.h +++ b/storageapi/src/vespa/storageapi/message/visitor.h @@ -186,12 +186,12 @@ public: document::BucketId bucketId; Timestamp timestamp; - BucketTimestampPair() : bucketId(), timestamp(0) {} - BucketTimestampPair(const document::BucketId& bucket, - const Timestamp& ts) - : bucketId(bucket), timestamp(ts) {} + BucketTimestampPair() noexcept : bucketId(), timestamp(0) {} + BucketTimestampPair(const document::BucketId& bucket, const Timestamp& ts) noexcept + : bucketId(bucket), timestamp(ts) + {} - bool operator==(const BucketTimestampPair& other) const { + bool operator==(const BucketTimestampPair& other) const noexcept { return (bucketId == other.bucketId && timestamp && other.timestamp); } }; @@ -203,7 +203,7 @@ private: public: VisitorInfoCommand(); - ~VisitorInfoCommand(); + ~VisitorInfoCommand() override; void setErrorCode(const ReturnCode& code) { _error = code; } void setCompleted() { _completed = true; } diff --git a/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp b/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp index d51bd57e942..13b396f5284 100644 --- a/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp @@ -30,7 +30,7 @@ struct SubFieldTerm vespalib::string _field_name; const QueryTerm* _term; public: - SubFieldTerm(vespalib::string field_name, const QueryTerm* term) + SubFieldTerm(vespalib::string field_name, const QueryTerm* term) noexcept : _field_name(std::move(field_name)), _term(term) { diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h index 9f1887c3b53..eb3879863a5 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h @@ -57,7 +57,7 @@ private: * @param fid the field id of the attribute field. * @param attr a guard to the attribute vector. **/ - AttrInfo(vsm::FieldIdT fid, search::AttributeGuard::UP attr) : + AttrInfo(vsm::FieldIdT fid, search::AttributeGuard::UP attr) noexcept : _field(fid), _ascending(true), _converter(nullptr), @@ -71,7 +71,7 @@ private: * @param ascending whether this attribute should be sorted ascending or not. * @param converter is a converter to apply to the attribute before sorting. **/ - AttrInfo(vsm::FieldIdT fid, search::AttributeGuard::UP attr, bool ascending, const search::common::BlobConverter * converter) : + AttrInfo(vsm::FieldIdT fid, search::AttributeGuard::UP attr, bool ascending, const search::common::BlobConverter * converter) noexcept : _field(fid), _ascending(ascending), _converter(converter), diff --git a/vbench/src/vbench/core/time_queue.h b/vbench/src/vbench/core/time_queue.h index 2af6f3edbcd..5237a6bc0fb 100644 --- a/vbench/src/vbench/core/time_queue.h +++ b/vbench/src/vbench/core/time_queue.h @@ -21,14 +21,14 @@ private: struct Entry { std::unique_ptr<T> object; double time; - Entry(std::unique_ptr<T> obj, double t) : object(std::move(obj)), time(t) {} - Entry(Entry &&rhs) : object(std::move(rhs.object)), time(rhs.time) {} - Entry &operator=(Entry &&rhs) { + Entry(std::unique_ptr<T> obj, double t) noexcept : object(std::move(obj)), time(t) {} + Entry(Entry &&rhs) noexcept : object(std::move(rhs.object)), time(rhs.time) {} + Entry &operator=(Entry &&rhs) noexcept { object = std::move(rhs.object); time = rhs.time; return *this; } - bool operator<(const Entry &rhs) const { + bool operator<(const Entry &rhs) const noexcept { return (time < rhs.time); } }; @@ -42,6 +42,7 @@ private: public: TimeQueue(double window, double tick); + ~TimeQueue(); void close() override; void discard(); void insert(std::unique_ptr<T> obj, double time); diff --git a/vbench/src/vbench/core/time_queue.hpp b/vbench/src/vbench/core/time_queue.hpp index 4a70e258935..0a1a74d72db 100644 --- a/vbench/src/vbench/core/time_queue.hpp +++ b/vbench/src/vbench/core/time_queue.hpp @@ -13,6 +13,9 @@ TimeQueue<T>::TimeQueue(double window, double tick) { } +template<typename T> +TimeQueue<T>::~TimeQueue() = default; + template <typename T> void TimeQueue<T>::close() diff --git a/vespalib/src/tests/delegatelist/delegatelist.cpp b/vespalib/src/tests/delegatelist/delegatelist.cpp index 070864dd85a..4dc7e5c97d7 100644 --- a/vespalib/src/tests/delegatelist/delegatelist.cpp +++ b/vespalib/src/tests/delegatelist/delegatelist.cpp @@ -77,15 +77,15 @@ struct Command int cmd; int cnt; Handler *handler; - Command(DL *dl_, int cmd_, int cnt_, Handler *handler_) + Command(DL *dl_, int cmd_, int cnt_, Handler *handler_) noexcept : dl(dl_), cmd(cmd_), cnt(cnt_), handler(handler_) {} - Command(const Command &rhs) + Command(const Command &rhs) noexcept : dl(rhs.dl), cmd(rhs.cmd), cnt(rhs.cnt), handler(rhs.handler) {} - Command &operator=(const Command &rhs) { + Command &operator=(const Command &rhs) noexcept { memcpy(this, &rhs, sizeof(Command)); return *this; } - bool operator==(const Command &rhs) { + bool operator==(const Command &rhs) noexcept { return memcmp(this, &rhs, sizeof(Command)) == 0; } }; diff --git a/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp b/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp index 1ba368b39a3..29a82138d29 100644 --- a/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp +++ b/vespalib/src/tests/explore_modern_cpp/explore_modern_cpp_test.cpp @@ -5,7 +5,7 @@ TEST("verify how std::function copies lambda closures") { size_t count = 0; size_t value = 0; - auto closure = [count,&value]()mutable{ ++count; value += count; }; + auto closure = [count,&value]() mutable noexcept { ++count; value += count; }; closure(); EXPECT_EQUAL(0u, count); EXPECT_EQUAL(1u, value); // +1 diff --git a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp index 434cb8d6a69..eca43ea5cec 100644 --- a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp +++ b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp @@ -11,7 +11,7 @@ using namespace vespalib; struct ResultSetter : public AsyncResolver::ResultHandler { SocketAddress &addr; std::atomic<bool> done; - ResultSetter(SocketAddress &addr_out) : addr(addr_out), done(false) {} + ResultSetter(SocketAddress &addr_out) noexcept : addr(addr_out), done(false) {} void handle_result(SocketAddress result) override { addr = result; done = true; @@ -31,7 +31,7 @@ struct MyClock : public AsyncResolver::Clock { struct BlockingHostResolver : public AsyncResolver::HostResolver { CountDownLatch callers; Gate barrier; - BlockingHostResolver(size_t num_callers) + BlockingHostResolver(size_t num_callers) noexcept : callers(num_callers), barrier() {} vespalib::string ip_address(const vespalib::string &) override { callers.countDown(); diff --git a/vespalib/src/tests/priority_queue/priority_queue_test.cpp b/vespalib/src/tests/priority_queue/priority_queue_test.cpp index 3457c2bde6b..af8dd853c6c 100644 --- a/vespalib/src/tests/priority_queue/priority_queue_test.cpp +++ b/vespalib/src/tests/priority_queue/priority_queue_test.cpp @@ -154,11 +154,11 @@ TEST("require that priority queue works with move-only objects") { struct MyItem { int value; int *ref; - MyItem(int v, int &r) : value(v), ref(&r) {} - MyItem(const MyItem &) = delete; - MyItem &operator=(const MyItem &) = delete; - MyItem(MyItem &&rhs) : value(rhs.value), ref(rhs.ref) { rhs.ref = 0; } - MyItem &operator=(MyItem &&rhs) { + MyItem(int v, int &r) noexcept : value(v), ref(&r) {} + MyItem(const MyItem &) noexcept = delete; + MyItem &operator=(const MyItem &) noexcept = delete; + MyItem(MyItem &&rhs) noexcept : value(rhs.value), ref(rhs.ref) { rhs.ref = 0; } + MyItem &operator=(MyItem &&rhs) noexcept { value = rhs.value; ref = rhs.ref; rhs.ref = 0; diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp index e86a9ad020a..d6f5c2ba65d 100644 --- a/vespalib/src/tests/stllike/hash_test.cpp +++ b/vespalib/src/tests/stllike/hash_test.cpp @@ -15,14 +15,14 @@ namespace { struct Foo { int i; - Foo() : i(0) {} - Foo(int i_) : i(i_) {} + Foo() noexcept : i(0) {} + Foo(int i_) noexcept : i(i_) {} - bool operator==(const Foo& f) const + bool operator==(const Foo& f) const noexcept { return (i == f.i); } struct hash { - size_t operator() (const Foo& f) const { + size_t operator() (const Foo& f) const noexcept { return (f.i % 16); } }; @@ -332,10 +332,10 @@ TEST("test hash map with simple key and value type") class S { public: - explicit S(uint64_t l=0) : _a(l&0xfffffffful), _b(l>>32) { } + explicit S(uint64_t l=0) noexcept : _a(l&0xfffffffful), _b(l>>32) { } uint32_t hash() const { return _a; } uint32_t a() const { return _a; } - friend bool operator == (const S & a, const S & b) { return a._a == b._a && a._b == b._b; } + friend bool operator == (const S & a, const S & b) noexcept { return a._a == b._a && a._b == b._b; } private: uint32_t _a, _b; }; diff --git a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp index 72a0c93c719..faee7680426 100644 --- a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp +++ b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp @@ -71,13 +71,13 @@ class Gid { public: struct hash { - size_t operator () (const Gid & g) const { return g.getGid()[0]; } + size_t operator () (const Gid & g) const noexcept { return g.getGid()[0]; } }; - Gid(unsigned int v=0) : _gid() { _gid[0] = _gid[1] = _gid[2] = v; } + Gid(unsigned int v=0) noexcept : _gid() { _gid[0] = _gid[1] = _gid[2] = v; } const unsigned int * getGid() const { return _gid; } - int cmp(const Gid & b) const { return memcmp(_gid, b._gid, sizeof(_gid)); } - bool operator < (const Gid & b) const { return cmp(b) < 0; } - bool operator == (const Gid & b) const { return cmp(b) == 0; } + int cmp(const Gid & b) const noexcept { return memcmp(_gid, b._gid, sizeof(_gid)); } + bool operator < (const Gid & b) const noexcept { return cmp(b) < 0; } + bool operator == (const Gid & b) const noexcept { return cmp(b) == 0; } private: unsigned int _gid[3]; }; @@ -85,15 +85,15 @@ private: class Slot { public: - Slot(unsigned int v=0) : _gid(v) { } + Slot(unsigned int v=0) noexcept : _gid(v) { } const Gid & getGid() const { return _gid; } - int cmp(const Slot & b) const { return _gid.cmp(b.getGid()); } + int cmp(const Slot & b) const noexcept { return _gid.cmp(b.getGid()); } private: Gid _gid; }; struct IndirectCmp : public std::binary_function<Slot*, Slot*, bool> { - bool operator()(const Slot* s1, const Slot* s2) { + bool operator() (const Slot* s1, const Slot* s2) noexcept { return s1->cmp(*s2) < 0; } }; diff --git a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp index a61f9fb5bca..2c1463e506a 100644 --- a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp +++ b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp @@ -15,7 +15,7 @@ struct WorkContext { uint64_t _generation; - WorkContext() + WorkContext() noexcept : _generation(0) { } diff --git a/vespalib/src/vespa/vespalib/btree/btree_key_data.h b/vespalib/src/vespa/vespalib/btree/btree_key_data.h index dc44faf00a9..5d4929694d5 100644 --- a/vespalib/src/vespa/vespalib/btree/btree_key_data.h +++ b/vespalib/src/vespa/vespalib/btree/btree_key_data.h @@ -28,12 +28,12 @@ public: KeyT _key; DataT _data; - BTreeKeyData() + BTreeKeyData() noexcept : _key(), _data() {} - BTreeKeyData(const KeyT &key, const DataT &data) + BTreeKeyData(const KeyT &key, const DataT &data) noexcept : _key(key), _data(data) {} @@ -60,9 +60,9 @@ public: KeyT _key; - BTreeKeyData() : _key() {} + BTreeKeyData() noexcept : _key() {} - BTreeKeyData(const KeyT &key, const BTreeNoLeafData &) + BTreeKeyData(const KeyT &key, const BTreeNoLeafData &) noexcept : _key(key) { } diff --git a/vespalib/src/vespa/vespalib/data/databuffer.cpp b/vespalib/src/vespa/vespalib/data/databuffer.cpp index 04c4b1e225b..6b98226e50e 100644 --- a/vespalib/src/vespa/vespalib/data/databuffer.cpp +++ b/vespalib/src/vespa/vespalib/data/databuffer.cpp @@ -11,7 +11,7 @@ size_t padbefore(size_t alignment, const char *buf) { } } -DataBuffer::DataBuffer(size_t len, size_t alignment, const Alloc & initial) +DataBuffer::DataBuffer(size_t len, size_t alignment, const Alloc & initial) noexcept : _alignment(alignment), _externalBuf(nullptr), _bufstart(nullptr), diff --git a/vespalib/src/vespa/vespalib/data/databuffer.h b/vespalib/src/vespa/vespalib/data/databuffer.h index 7c4cd63a7b1..93da2b92379 100644 --- a/vespalib/src/vespa/vespalib/data/databuffer.h +++ b/vespalib/src/vespa/vespalib/data/databuffer.h @@ -44,8 +44,8 @@ public: typedef std::unique_ptr<DataBuffer> UP; DataBuffer(const DataBuffer &) = delete; DataBuffer &operator=(const DataBuffer &) = delete; - DataBuffer(DataBuffer &&) = default; - DataBuffer &operator=(DataBuffer &&) = default; + DataBuffer(DataBuffer &&) noexcept = default; + DataBuffer &operator=(DataBuffer &&) noexcept = default; /** * Construct a databuffer. @@ -53,7 +53,7 @@ public: * @param len the initial size of the buffer. * @param alignment required memory alignment for data start **/ - DataBuffer(size_t len = 1024, size_t alignment = 1, const Alloc & initial = Alloc::alloc(0)); + DataBuffer(size_t len = 1024, size_t alignment = 1, const Alloc & initial = Alloc::alloc(0)) noexcept; /** * Construct a databuffer using externally allocated memory. Note @@ -63,7 +63,7 @@ public: * @param buf pointer to preallocated memory * @param len length of preallocated memory **/ - DataBuffer(void *buf, size_t len) : + DataBuffer(void *buf, size_t len) noexcept : _alignment(1), _externalBuf(static_cast<char *>(buf)), _bufstart(_externalBuf), @@ -73,7 +73,7 @@ public: _buffer(Alloc::alloc(0)) { } - DataBuffer(const void *buf, size_t len) : + DataBuffer(const void *buf, size_t len) noexcept : _alignment(1), _externalBuf(static_cast<char *>(const_cast<void *>(buf))), _bufstart(_externalBuf), diff --git a/vespalib/src/vespa/vespalib/data/slime/slime.h b/vespalib/src/vespa/vespalib/data/slime/slime.h index 6523cd1dac0..3ee608799a6 100644 --- a/vespalib/src/vespa/vespalib/data/slime/slime.h +++ b/vespalib/src/vespa/vespalib/data/slime/slime.h @@ -86,7 +86,7 @@ public: ~Slime(); - Slime(Slime &&rhs) : + Slime(Slime &&rhs) noexcept : _names(std::move(rhs._names)), _stash(std::move(rhs._stash)), _root(std::move(rhs._root)) diff --git a/vespalib/src/vespa/vespalib/datastore/entryref.h b/vespalib/src/vespa/vespalib/datastore/entryref.h index 51a4e0699fc..4a5123ee1b3 100644 --- a/vespalib/src/vespa/vespalib/datastore/entryref.h +++ b/vespalib/src/vespa/vespalib/datastore/entryref.h @@ -13,13 +13,13 @@ class EntryRef { protected: uint32_t _ref; public: - EntryRef() : _ref(0u) { } - explicit EntryRef(uint32_t ref_) : _ref(ref_) { } - uint32_t ref() const { return _ref; } - bool valid() const { return _ref != 0u; } - bool operator==(const EntryRef &rhs) const { return _ref == rhs._ref; } - bool operator!=(const EntryRef &rhs) const { return _ref != rhs._ref; } - bool operator <(const EntryRef &rhs) const { return _ref < rhs._ref; } + EntryRef() noexcept : _ref(0u) { } + explicit EntryRef(uint32_t ref_) noexcept : _ref(ref_) { } + uint32_t ref() const noexcept { return _ref; } + bool valid() const noexcept { return _ref != 0u; } + bool operator==(const EntryRef &rhs) const noexcept { return _ref == rhs._ref; } + bool operator!=(const EntryRef &rhs) const noexcept { return _ref != rhs._ref; } + bool operator <(const EntryRef &rhs) const noexcept { return _ref < rhs._ref; } }; /** @@ -29,9 +29,9 @@ public: template <uint32_t OffsetBits, uint32_t BufferBits = 32u - OffsetBits> class EntryRefT : public EntryRef { public: - EntryRefT() : EntryRef() {} - EntryRefT(size_t offset_, uint32_t bufferId_); - EntryRefT(const EntryRef & ref_) : EntryRef(ref_.ref()) {} + EntryRefT() noexcept : EntryRef() {} + EntryRefT(size_t offset_, uint32_t bufferId_) noexcept; + EntryRefT(const EntryRef & ref_) noexcept : EntryRef(ref_.ref()) {} size_t offset() const { return _ref & (offsetSize() - 1); } uint32_t bufferId() const { return _ref >> OffsetBits; } static size_t offsetSize() { return 1ul << OffsetBits; } @@ -55,10 +55,10 @@ private: typedef EntryRefT<OffsetBits> ParentType; static const uint32_t PadConstant = ((1 << OffsetAlign) - 1); public: - AlignedEntryRefT() : ParentType() {} - AlignedEntryRefT(size_t offset_, uint32_t bufferId_) : + AlignedEntryRefT() noexcept : ParentType() {} + AlignedEntryRefT(size_t offset_, uint32_t bufferId_) noexcept : ParentType(align(offset_) >> OffsetAlign, bufferId_) {} - AlignedEntryRefT(const EntryRef & ref_) : ParentType(ref_) {} + AlignedEntryRefT(const EntryRef & ref_) noexcept : ParentType(ref_) {} size_t offset() const { return ParentType::offset() << OffsetAlign; } static size_t offsetSize() { return ParentType::offsetSize() << OffsetAlign; } static size_t align(size_t val) { return val + pad(val); } diff --git a/vespalib/src/vespa/vespalib/datastore/entryref.hpp b/vespalib/src/vespa/vespalib/datastore/entryref.hpp index 56ebe62dfab..34b8d5355e3 100644 --- a/vespalib/src/vespa/vespalib/datastore/entryref.hpp +++ b/vespalib/src/vespa/vespalib/datastore/entryref.hpp @@ -8,7 +8,7 @@ namespace vespalib::datastore { template <uint32_t OffsetBits, uint32_t BufferBits> -EntryRefT<OffsetBits, BufferBits>::EntryRefT(size_t offset_, uint32_t bufferId_) : +EntryRefT<OffsetBits, BufferBits>::EntryRefT(size_t offset_, uint32_t bufferId_) noexcept : EntryRef((bufferId_ << OffsetBits) + offset_) { ASSERT_ONCE_OR_LOG(offset_ < offsetSize(), "EntryRefT.offset_overflow", 10000); diff --git a/vespalib/src/vespa/vespalib/stllike/string.h b/vespalib/src/vespa/vespalib/stllike/string.h index 7d4ed06c411..f1207c1d9b8 100644 --- a/vespalib/src/vespa/vespalib/stllike/string.h +++ b/vespalib/src/vespa/vespalib/stllike/string.h @@ -180,7 +180,7 @@ public: small_string(const char * s) noexcept : _buf(_stack), _sz(s ? strlen(s) : 0) { init(s); } small_string(const void * s, size_type sz) noexcept : _buf(_stack), _sz(sz) { init(s); } small_string(stringref s) noexcept : _buf(_stack), _sz(s.size()) { init(s.data()); } - small_string(const std::string & s) : _buf(_stack), _sz(s.size()) { init(s.data()); } + small_string(const std::string & s) noexcept : _buf(_stack), _sz(s.size()) { init(s.data()); } small_string(small_string && rhs) noexcept : _sz(rhs.size()), _bufferSize(rhs._bufferSize) { diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 29285932f63..1303e7ffdee 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -510,13 +510,13 @@ Alloc::allocMMap(size_t sz) } Alloc -Alloc::alloc() +Alloc::alloc() noexcept { return Alloc(&AutoAllocator::getDefault()); } Alloc -Alloc::alloc(size_t sz, size_t mmapLimit, size_t alignment) +Alloc::alloc(size_t sz, size_t mmapLimit, size_t alignment) noexcept { return Alloc(&AutoAllocator::getAllocator(mmapLimit, alignment), sz); } diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h index 449cdde5fc7..cf7135736e5 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.h +++ b/vespalib/src/vespa/vespalib/util/alloc.h @@ -81,18 +81,18 @@ public: } return *this; } - Alloc() : _alloc(nullptr, 0), _allocator(nullptr) { } + Alloc() noexcept : _alloc(nullptr, 0), _allocator(nullptr) { } ~Alloc() { if (_alloc.first != nullptr) { _allocator->free(_alloc); _alloc.first = nullptr; } } - void swap(Alloc & rhs) { + void swap(Alloc & rhs) noexcept { std::swap(_alloc, rhs._alloc); std::swap(_allocator, rhs._allocator); } - Alloc create(size_t sz) const { + Alloc create(size_t sz) const noexcept { return (sz == 0) ? Alloc(_allocator) : Alloc(_allocator, sz); } @@ -103,11 +103,11 @@ public: * Optional alignment is assumed to be <= system page size, since mmap * is always used when size is above limit. */ - static Alloc alloc(size_t sz, size_t mmapLimit = MemoryAllocator::HUGEPAGE_SIZE, size_t alignment=0); - static Alloc alloc(); + static Alloc alloc(size_t sz, size_t mmapLimit = MemoryAllocator::HUGEPAGE_SIZE, size_t alignment=0) noexcept; + static Alloc alloc() noexcept; private: - Alloc(const MemoryAllocator * allocator, size_t sz) : _alloc(allocator->alloc(sz)), _allocator(allocator) { } - Alloc(const MemoryAllocator * allocator) : _alloc(nullptr, 0), _allocator(allocator) { } + Alloc(const MemoryAllocator * allocator, size_t sz) noexcept : _alloc(allocator->alloc(sz)), _allocator(allocator) { } + Alloc(const MemoryAllocator * allocator) noexcept : _alloc(nullptr, 0), _allocator(allocator) { } void clear() { _alloc.first = nullptr; _alloc.second = 0; diff --git a/vespalib/src/vespa/vespalib/util/arrayqueue.hpp b/vespalib/src/vespa/vespalib/util/arrayqueue.hpp index 17a8c02dbf5..9af446e7a0f 100644 --- a/vespalib/src/vespa/vespalib/util/arrayqueue.hpp +++ b/vespalib/src/vespa/vespalib/util/arrayqueue.hpp @@ -101,15 +101,16 @@ public: /** * Create an empty queue with an initial capacity of 0. **/ - ArrayQueue() : _data(0), _capacity(0), _used(0), _skew(0) {} + ArrayQueue() noexcept : _data(0), _capacity(0), _used(0), _skew(0) {} /** * Create an empty queue with the given initial capacity. * * @param cap initial capacity **/ - explicit ArrayQueue(uint32_t cap) : _data((T*)malloc(sizeof(T) * cap)), - _capacity(cap), _used(0), _skew(0) {} + explicit ArrayQueue(uint32_t cap) noexcept + : _data((T*)malloc(sizeof(T) * cap)), _capacity(cap), _used(0), _skew(0) + {} /** * Create a queue that is a copy of another queue. Now with funky @@ -119,8 +120,8 @@ public: * @param q the queue that should be copied **/ ArrayQueue(typename std::conditional<is_copyable<T>::value, void_tag, const ArrayQueue &>::type q) = delete; - ArrayQueue(typename std::conditional<is_copyable<T>::value, const ArrayQueue &, void_tag>::type q) : _data((T*)malloc(sizeof(T) * q._capacity)), - _capacity(q._capacity), _used(0), _skew(0) + ArrayQueue(typename std::conditional<is_copyable<T>::value, const ArrayQueue &, void_tag>::type q) + : _data((T*)malloc(sizeof(T) * q._capacity)), _capacity(q._capacity), _used(0), _skew(0) { try { q.copyInto(*this); @@ -136,7 +137,7 @@ public: * * @param q the queue that should be moved **/ - ArrayQueue(ArrayQueue &&q) : _data(0), _capacity(0), _used(0), _skew(0) + ArrayQueue(ArrayQueue &&q) noexcept : _data(0), _capacity(0), _used(0), _skew(0) { swap(q); } @@ -358,7 +359,7 @@ public: * * @param q the queue we want to swap state with **/ - void swap(ArrayQueue<T> &q) { + void swap(ArrayQueue<T> &q) noexcept { std::swap(_data, q._data); std::swap(_capacity, q._capacity); std::swap(_used, q._used); diff --git a/vespalib/src/vespa/vespalib/util/compressionconfig.h b/vespalib/src/vespa/vespalib/util/compressionconfig.h index c0010e8e05c..88563c181a1 100644 --- a/vespalib/src/vespa/vespalib/util/compressionconfig.h +++ b/vespalib/src/vespa/vespalib/util/compressionconfig.h @@ -20,15 +20,15 @@ struct CompressionConfig { ZSTD = 7 }; - CompressionConfig() + CompressionConfig() noexcept : type(NONE), compressionLevel(0), threshold(90), minSize(0) {} - CompressionConfig(Type t) + CompressionConfig(Type t) noexcept : type(t), compressionLevel(9), threshold(90), minSize(0) {} - CompressionConfig(Type t, uint8_t level, uint8_t minRes) + CompressionConfig(Type t, uint8_t level, uint8_t minRes) noexcept : type(t), compressionLevel(level), threshold(minRes), minSize(0) {} - CompressionConfig(Type t, uint8_t lvl, uint8_t minRes, size_t minSz) + CompressionConfig(Type t, uint8_t lvl, uint8_t minRes, size_t minSz) noexcept : type(t), compressionLevel(lvl), threshold(minRes), minSize(minSz) {} bool operator==(const CompressionConfig& o) const { diff --git a/vespalib/src/vespa/vespalib/util/count_down_latch.h b/vespalib/src/vespa/vespalib/util/count_down_latch.h index 66ef1e44cee..420be8f7ab2 100644 --- a/vespalib/src/vespa/vespalib/util/count_down_latch.h +++ b/vespalib/src/vespa/vespalib/util/count_down_latch.h @@ -37,7 +37,7 @@ public: * * @param cnt initial count **/ - CountDownLatch(uint32_t cnt) : _lock(), _cond(), _count(cnt) {} + CountDownLatch(uint32_t cnt) noexcept : _lock(), _cond(), _count(cnt) {} /** * Count down this latch. When the count reaches 0, all threads diff --git a/vespalib/src/vespa/vespalib/util/gate.h b/vespalib/src/vespa/vespalib/util/gate.h index 7d913a7a039..5505a3676df 100644 --- a/vespalib/src/vespa/vespalib/util/gate.h +++ b/vespalib/src/vespa/vespalib/util/gate.h @@ -16,7 +16,7 @@ public: /** * Sets the initial count to 1. **/ - Gate() : CountDownLatch(1) {} + Gate() noexcept : CountDownLatch(1) {} }; } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/memory.h b/vespalib/src/vespa/vespalib/util/memory.h index f1c7c7820f1..2e0d631725a 100644 --- a/vespalib/src/vespa/vespalib/util/memory.h +++ b/vespalib/src/vespa/vespalib/util/memory.h @@ -200,7 +200,7 @@ public: * with default sz=0 you get an empty container * @param sz the number of bytes to allocate **/ - MallocPtr(const size_t sz=0) : _sz(sz), _p(_sz ? malloc(sz) : nullptr) { + MallocPtr(const size_t sz=0) noexcept : _sz(sz), _p(_sz ? malloc(sz) : nullptr) { if (_p == nullptr) { _sz = 0; } @@ -208,7 +208,7 @@ public: /** @brief destructor doing free() if needed */ ~MallocPtr() { cleanup(); } - MallocPtr(MallocPtr && rhs) : + MallocPtr(MallocPtr && rhs) noexcept : _sz(rhs.size()), _p(rhs._p) { rhs._sz = 0; @@ -221,7 +221,7 @@ public: * Does deep copy of contents (using memcpy). * @param rhs container to copy **/ - MallocPtr(const MallocPtr & rhs) + MallocPtr(const MallocPtr & rhs) noexcept : _sz(rhs.size()), _p(_sz ? malloc(_sz) : nullptr) { if (_p == nullptr) { @@ -238,14 +238,14 @@ public: * works like destruct + copy construct. * @param rhs container to copy **/ - MallocPtr & operator = (const MallocPtr & rhs) { + MallocPtr & operator = (const MallocPtr & rhs) noexcept { if (this != &rhs) { MallocPtr tmp(rhs); swap(tmp); } return *this; } - MallocPtr & operator = (MallocPtr && rhs) { + MallocPtr & operator = (MallocPtr && rhs) noexcept { if (this != &rhs) { cleanup(); _sz = rhs._sz; @@ -261,7 +261,7 @@ public: * * does not copy anything, just swaps pointers. **/ - void swap(MallocPtr & rhs) { + void swap(MallocPtr & rhs) noexcept { std::swap(_sz, rhs._sz); std::swap(_p, rhs._p); } @@ -307,7 +307,7 @@ public: } } private: - void cleanup() { + void cleanup() noexcept { if (_p) { free(_p); _p = nullptr; @@ -350,7 +350,7 @@ public: } /** @brief move constructor, takes over ownership */ - CloneablePtr(std::unique_ptr<T> &&rhs) + CloneablePtr(std::unique_ptr<T> &&rhs) noexcept : _p(rhs.release()) { } @@ -373,7 +373,7 @@ public: } /** @brief swap contents */ - void swap(CloneablePtr & rhs) { std::swap(_p, rhs._p); } + void swap(CloneablePtr & rhs) noexcept { std::swap(_p, rhs._p); } /** @brief value access */ const T * get() const { return _p; } diff --git a/vespalib/src/vespa/vespalib/util/sync.h b/vespalib/src/vespa/vespalib/util/sync.h index 8458bc19629..043bb477c89 100644 --- a/vespalib/src/vespa/vespalib/util/sync.h +++ b/vespalib/src/vespa/vespalib/util/sync.h @@ -32,9 +32,10 @@ public: * * Creates a Lock that has mutex instrumentation disabled. **/ - Lock() : _mutex() {} + Lock() noexcept : _mutex() {} + //TODO Remove The below methods are very bad and have a dodgy history. Lock(const Lock &) : Lock() { } - Lock(Lock &&) : Lock() { } + Lock(Lock &&) noexcept : Lock() { } Lock &operator=(const Lock &) { return *this; } Lock &operator=(Lock &&) { return *this; } }; @@ -66,9 +67,10 @@ public: * * Creates a Monitor that has mutex instrumentation disabled. **/ - Monitor() : Lock(), _cond() {} + Monitor() noexcept : Lock(), _cond() {} + //TODO Remove The below methods are very bad and have a dodgy history. Monitor(const Monitor &) : Monitor() { } - Monitor(Monitor &&) : Monitor() { } + Monitor(Monitor &&) noexcept : Monitor() { } Monitor &operator=(const Monitor &) { return *this; } Monitor &operator=(Monitor &&) { return *this; } }; |