diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-28 06:42:13 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-28 10:08:43 +0000 |
commit | 02b5efaa3bbc043e50e2c64b968241f842c3cffc (patch) | |
tree | b9f9ea83f0dd49656791439322d5ba3d3b6be0b9 /storage | |
parent | bb59611ce9611986ee97f19d2bb725dc1d160074 (diff) |
Avoid the need for clone by using unique_ptr.
Diffstat (limited to 'storage')
4 files changed, 6 insertions, 8 deletions
diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp index 5aa5845ac4c..c7b50b69779 100644 --- a/storage/src/tests/distributor/externaloperationhandlertest.cpp +++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp @@ -595,7 +595,7 @@ TEST_F(ExternalOperationHandlerTest, non_trivial_updates_are_rejected_if_feed_is auto cmd = makeUpdateCommand("testdoctype1", "id:foo:testdoctype1::foo"); const auto* doc_type = _testDocMan.getTypeRepo().getDocumentType("testdoctype1"); document::FieldUpdate upd(doc_type->getField("title")); - upd.addUpdate(document::AssignValueUpdate(document::StringFieldValue("new value"))); + upd.addUpdate(std::make_unique<document::AssignValueUpdate>(document::StringFieldValue("new value"))); cmd->getUpdate()->addUpdate(std::move(upd)); ASSERT_NO_FATAL_FAILURE(start_operation_verify_rejected(std::move(cmd))); diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp index 7a7e53a1d2c..df786902965 100644 --- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp +++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp @@ -296,7 +296,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState, *_repo, *_doc_type, document::DocumentId("id:ns:" + _doc_type->getName() + "::1")); document::FieldUpdate fup(_doc_type->getField("headerval")); - fup.addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 10)); + fup.addUpdate(std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 10)); update->addUpdate(std::move(fup)); } else { // Create an update to a different doctype than the one returned as @@ -306,7 +306,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState, *_repo, *badDocType, document::DocumentId("id:ns:" + _doc_type->getName() + "::1")); document::FieldUpdate fup(badDocType->getField("onlyinchild")); - fup.addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 10)); + fup.addUpdate(std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 10)); update->addUpdate(std::move(fup)); } update->setCreateIfNonExistent(options._createIfNonExistent); diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp index 0adeff5bc34..dfb245b2a52 100644 --- a/storage/src/tests/persistence/persistencetestutils.cpp +++ b/storage/src/tests/persistence/persistencetestutils.cpp @@ -225,8 +225,7 @@ PersistenceTestUtils::createBodyUpdate(const document::DocumentId& docId, const { const DocumentType* docType(getTypeRepo()->getDocumentType("testdoctype1")); auto update = std::make_shared<document::DocumentUpdate>(*getTypeRepo(), *docType, docId); - auto assignUpdate = std::make_shared<document::AssignValueUpdate>(updateValue); - update->addUpdate(std::move(document::FieldUpdate(docType->getField("content")).addUpdate(*assignUpdate))); + update->addUpdate(std::move(document::FieldUpdate(docType->getField("content")).addUpdate(std::make_unique<document::AssignValueUpdate>(updateValue)))); return update; } @@ -235,8 +234,7 @@ PersistenceTestUtils::createHeaderUpdate(const document::DocumentId& docId, cons { const DocumentType* docType(getTypeRepo()->getDocumentType("testdoctype1")); auto update = std::make_shared<document::DocumentUpdate>(*getTypeRepo(), *docType, docId); - auto assignUpdate = std::make_shared<document::AssignValueUpdate>(updateValue); - update->addUpdate(std::move(document::FieldUpdate(docType->getField("headerval")).addUpdate(*assignUpdate))); + update->addUpdate(std::move(document::FieldUpdate(docType->getField("headerval")).addUpdate(std::make_unique<document::AssignValueUpdate>(updateValue)))); return update; } diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp index 267569b0bc5..30a9886cf44 100644 --- a/storage/src/tests/persistence/testandsettest.cpp +++ b/storage/src/tests/persistence/testandsettest.cpp @@ -159,7 +159,7 @@ std::shared_ptr<api::UpdateCommand> TestAndSetTest::conditional_update_test(bool createIfMissing, api::Timestamp updateTimestamp) { auto docUpdate = std::make_shared<document::DocumentUpdate>(_env->_testDocMan.getTypeRepo(), testDoc->getType(), testDocId); - docUpdate->addUpdate(std::move(document::FieldUpdate(testDoc->getField("content")).addUpdate(document::AssignValueUpdate(NEW_CONTENT)))); + docUpdate->addUpdate(std::move(document::FieldUpdate(testDoc->getField("content")).addUpdate(std::make_unique<document::AssignValueUpdate>(NEW_CONTENT)))); docUpdate->setCreateIfNonExistent(createIfMissing); auto updateUp = std::make_unique<api::UpdateCommand>(BUCKET, docUpdate, updateTimestamp); |