diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-22 10:26:30 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-22 10:26:30 +0100 |
commit | c6af4d6ed59235d8fec52aeddfcd9a65607139ff (patch) | |
tree | c32dc712818a9064b03ff4020d369094a24a2e71 /common/storage/entitystore.cpp | |
parent | b6981d94fb5fb12024738b639f9e389dd04578da (diff) | |
download | sink-c6af4d6ed59235d8fec52aeddfcd9a65607139ff.tar.gz sink-c6af4d6ed59235d8fec52aeddfcd9a65607139ff.zip |
Avoid unnecessary transactions.
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r-- | common/storage/entitystore.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 3512e34..79314ad 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -309,11 +309,19 @@ void EntityStore::cleanupRevision(qint64 revision) | |||
309 | 309 | ||
310 | void EntityStore::cleanupRevisions(qint64 revision) | 310 | void EntityStore::cleanupRevisions(qint64 revision) |
311 | { | 311 | { |
312 | bool implicitTransaction = false; | ||
313 | if (!d->transaction) { | ||
314 | startTransaction(Sink::Storage::DataStore::ReadWrite); | ||
315 | implicitTransaction = true; | ||
316 | } | ||
312 | const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction); | 317 | const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction); |
313 | SinkTrace() << "Cleaning up from " << lastCleanRevision + 1 << " to " << revision; | 318 | SinkTrace() << "Cleaning up from " << lastCleanRevision + 1 << " to " << revision; |
314 | for (qint64 rev = lastCleanRevision + 1; rev <= revision; rev++) { | 319 | for (qint64 rev = lastCleanRevision + 1; rev <= revision; rev++) { |
315 | cleanupRevision(revision); | 320 | cleanupRevision(revision); |
316 | } | 321 | } |
322 | if (implicitTransaction) { | ||
323 | commitTransaction(); | ||
324 | } | ||
317 | } | 325 | } |
318 | 326 | ||
319 | QVector<QByteArray> EntityStore::fullScan(const QByteArray &type) | 327 | QVector<QByteArray> EntityStore::fullScan(const QByteArray &type) |