diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-14 13:12:42 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-14 13:12:42 +0200 |
commit | 6bca7c8fb40c81c4cb02790689fe94f37e233edf (patch) | |
tree | 80188c7c417b8bab76869ef85dd02d07c25d04ca /common/synchronizerstore.cpp | |
parent | d135fa0387672c10bad70b44867470affe1a3232 (diff) | |
download | sink-6bca7c8fb40c81c4cb02790689fe94f37e233edf.tar.gz sink-6bca7c8fb40c81c4cb02790689fe94f37e233edf.zip |
Avoid creating unnecessary rid mappings
Diffstat (limited to 'common/synchronizerstore.cpp')
-rw-r--r-- | common/synchronizerstore.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/synchronizerstore.cpp b/common/synchronizerstore.cpp index 0d1e154..2bd54f2 100644 --- a/common/synchronizerstore.cpp +++ b/common/synchronizerstore.cpp | |||
@@ -49,7 +49,7 @@ void SynchronizerStore::updateRemoteId(const QByteArray &bufferType, const QByte | |||
49 | recordRemoteId(bufferType, localId, remoteId); | 49 | recordRemoteId(bufferType, localId, remoteId); |
50 | } | 50 | } |
51 | 51 | ||
52 | QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId) | 52 | QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId, bool insertIfMissing) |
53 | { | 53 | { |
54 | if (remoteId.isEmpty()) { | 54 | if (remoteId.isEmpty()) { |
55 | SinkWarning() << "Cannot resolve empty remote id for type: " << bufferType; | 55 | SinkWarning() << "Cannot resolve empty remote id for type: " << bufferType; |
@@ -58,7 +58,7 @@ QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, cons | |||
58 | // Lookup local id for remote id, or insert a new pair otherwise | 58 | // Lookup local id for remote id, or insert a new pair otherwise |
59 | Index index("rid.mapping." + bufferType, mTransaction); | 59 | Index index("rid.mapping." + bufferType, mTransaction); |
60 | QByteArray sinkId = index.lookup(remoteId); | 60 | QByteArray sinkId = index.lookup(remoteId); |
61 | if (sinkId.isEmpty()) { | 61 | if (sinkId.isEmpty() && insertIfMissing) { |
62 | sinkId = Sink::Storage::DataStore::generateUid(); | 62 | sinkId = Sink::Storage::DataStore::generateUid(); |
63 | index.add(remoteId, sinkId); | 63 | index.add(remoteId, sinkId); |
64 | Index("localid.mapping." + bufferType, mTransaction).add(sinkId, remoteId); | 64 | Index("localid.mapping." + bufferType, mTransaction).add(sinkId, remoteId); |