From 8e7794d5ad80f969ef90e3ff8b2ff1de0f2527c4 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 28 Jun 2023 21:09:42 +0000 Subject: Avoid maintaining copy constructor. --- .../searchcore/proton/server/documentdbconfig.cpp | 34 ++++++---------------- .../searchcore/proton/server/documentdbconfig.h | 2 ++ .../searchcore/proton/server/memoryconfigstore.cpp | 9 +++--- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp index cc8bc2c8b96..904e495e0f2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp @@ -98,31 +98,8 @@ DocumentDBConfig::DocumentDBConfig( { } -DocumentDBConfig:: -DocumentDBConfig(const DocumentDBConfig &cfg) - : _configId(cfg._configId), - _docTypeName(cfg._docTypeName), - _generation(cfg._generation), - _rankProfiles(cfg._rankProfiles), - _rankingConstants(cfg._rankingConstants), - _rankingExpressions(cfg._rankingExpressions), - _onnxModels(cfg._onnxModels), - _indexschema(cfg._indexschema), - _attributes(cfg._attributes), - _summary(cfg._summary), - _juniperrc(cfg._juniperrc), - _documenttypes(cfg._documenttypes), - _repo(cfg._repo), - _importedFields(cfg._importedFields), - _tuneFileDocumentDB(cfg._tuneFileDocumentDB), - _schema(cfg._schema), - _maintenance(cfg._maintenance), - _storeConfig(cfg._storeConfig), - _threading_service_config(cfg._threading_service_config), - _alloc_config(cfg._alloc_config), - _orig(cfg._orig), - _delayedAttributeAspects(false) -{ } +DocumentDBConfig::DocumentDBConfig(const DocumentDBConfig &cfg) = default; + DocumentDBConfig::~DocumentDBConfig() = default; @@ -348,6 +325,13 @@ DocumentDBConfig::makeDelayedAttributeAspectConfig(const SP &newCfg, const Docum return result; } +DocumentDBConfig::SP +DocumentDBConfig::make_copy() const { + auto copy = std::make_shared(*this); + copy->_delayedAttributeAspects = false; + return copy; +} + const document::DocumentType * DocumentDBConfig::getDocumentType() const { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h index 848e68ce0f2..ce8181716ad 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h @@ -174,6 +174,7 @@ public: const vespalib::string &docTypeName) noexcept; DocumentDBConfig(const DocumentDBConfig &cfg); + DocumentDBConfig & operator=(const DocumentDBConfig &cfg) = delete; ~DocumentDBConfig(); const vespalib::string &getConfigId() const { return _configId; } @@ -250,6 +251,7 @@ public: * reprocessing. */ static SP makeDelayedAttributeAspectConfig(const SP &newCfg, const DocumentDBConfig &oldCfg); + SP make_copy() const; static std::shared_ptr build_schema(const AttributesConfig& attributes_config, diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp index 989254c7aa1..7db60bf4576 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp @@ -11,8 +11,8 @@ namespace proton { ConfigMaps::~ConfigMaps() = default; -MemoryConfigStore::MemoryConfigStore() : _maps(new ConfigMaps) {} -MemoryConfigStore::MemoryConfigStore(ConfigMaps::SP maps) : _maps(maps) {} +MemoryConfigStore::MemoryConfigStore() : _maps(std::make_shared()) {} +MemoryConfigStore::MemoryConfigStore(ConfigMaps::SP maps) : _maps(std::move(maps)) {} MemoryConfigStore::~MemoryConfigStore() = default; ConfigStore::SerialNum @@ -36,10 +36,9 @@ MemoryConfigStore::getPrevValidSerial(SerialNum serial) const { return *(--(_maps->_valid.lower_bound(serial))); } void -MemoryConfigStore::saveConfig(const DocumentDBConfig &config, - SerialNum serial) +MemoryConfigStore::saveConfig(const DocumentDBConfig &config, SerialNum serial) { - _maps->configs[serial] = std::make_shared(config); + _maps->configs[serial] = config.make_copy(); _maps->_valid.insert(serial); } void -- cgit v1.2.3