summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-01-30 17:33:28 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-01-30 17:33:28 +0100
commitca71cc7875c300a9c519380b128dd812b86df25e (patch)
treeba0f8ce139051c3a08cfe143e1b8df799eea3b21 /common
parent44fcf3643d0032cd7cbb75d9815b3ecfc2b2b6be (diff)
downloadsink-ca71cc7875c300a9c519380b128dd812b86df25e.tar.gz
sink-ca71cc7875c300a9c519380b128dd812b86df25e.zip
Less hardcoded numbers
Diffstat (limited to 'common')
-rw-r--r--common/storage_common.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp
index 78d4c84..057dce4 100644
--- a/common/storage_common.cpp
+++ b/common/storage_common.cpp
@@ -35,6 +35,7 @@ namespace Storage {
35 35
36static const char *s_internalPrefix = "__internal"; 36static const char *s_internalPrefix = "__internal";
37static const int s_internalPrefixSize = strlen(s_internalPrefix); 37static const int s_internalPrefixSize = strlen(s_internalPrefix);
38static const int s_lengthOfUid = 38;
38 39
39DbLayout::DbLayout() 40DbLayout::DbLayout()
40{ 41{
@@ -196,18 +197,18 @@ bool DataStore::isInternalKey(const QByteArray &key)
196QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision) 197QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision)
197{ 198{
198 Q_ASSERT(revision <= 9223372036854775807); 199 Q_ASSERT(revision <= 9223372036854775807);
199 Q_ASSERT(key.size() == 38); 200 Q_ASSERT(key.size() == s_lengthOfUid);
200 return key + QByteArray::number(revision).rightJustified(19, '0', false); 201 return key + QByteArray::number(revision).rightJustified(19, '0', false);
201} 202}
202 203
203QByteArray DataStore::uidFromKey(const QByteArray &key) 204QByteArray DataStore::uidFromKey(const QByteArray &key)
204{ 205{
205 return key.mid(0, 38); 206 return key.mid(0, s_lengthOfUid);
206} 207}
207 208
208qint64 DataStore::revisionFromKey(const QByteArray &key) 209qint64 DataStore::revisionFromKey(const QByteArray &key)
209{ 210{
210 return key.mid(39).toLongLong(); 211 return key.mid(s_lengthOfUid + 1).toLongLong();
211} 212}
212 213
213QByteArray DataStore::generateUid() 214QByteArray DataStore::generateUid()