From 9c8e4612403fc2accc26ac2b49670394972f1293 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 8 Dec 2016 17:43:07 +0100 Subject: One copy algorithm is enough. --- common/bufferadaptor.h | 13 ------------- common/domain/applicationdomaintype.h | 5 +++-- common/pipeline.cpp | 3 ++- 3 files changed, 5 insertions(+), 16 deletions(-) (limited to 'common') diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h index 8787d39..f6994d7 100644 --- a/common/bufferadaptor.h +++ b/common/bufferadaptor.h @@ -59,19 +59,6 @@ public: { } - MemoryBufferAdaptor(const BufferAdaptor &buffer, const QList &properties) : BufferAdaptor() - { - if (properties.isEmpty()) { - for (const auto &property : buffer.availableProperties()) { - mValues.insert(property, buffer.getProperty(property)); - } - } else { - for (const auto &property : properties) { - mValues.insert(property, buffer.getProperty(property)); - } - } - } - virtual ~MemoryBufferAdaptor() { } diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index be14513..7c3800d 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -122,7 +122,7 @@ struct Reference { QByteArray value; }; -void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList &properties, bool copyBlobs, bool pruneReferences); +void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList &properties = QList(), bool copyBlobs = false, bool pruneReferences = false); /** * The domain type interface has two purposes: @@ -155,7 +155,8 @@ public: template static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList properties = QList()) { - auto memoryAdaptor = QSharedPointer::create(*(domainType.mAdaptor), properties); + auto memoryAdaptor = QSharedPointer::create(); + copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, false, false); //mIdentifier internally still refers to the memory-mapped memory, we need to copy the memory or it will become invalid return QSharedPointer::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); } diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 7ee4b91..0eb6df5 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -168,7 +168,8 @@ KAsync::Job Pipeline::newEntity(void const *command, size_t size) } auto adaptor = adaptorFactory->createAdaptor(*entity); - auto memoryAdaptor = QSharedPointer::create(*(adaptor), adaptor->availableProperties()); + auto memoryAdaptor = QSharedPointer::create(); + Sink::ApplicationDomain::copyBuffer(*adaptor, *memoryAdaptor); d->revisionChanged = true; auto revision = d->entityStore.maxRevision(); -- cgit v1.2.3