No need to do two sql query for something that's always the same and
there are very few checksum types
return 0;
}
+ auto it = _checksymTypeCache.find(checksumType);
+ if (it != _checksymTypeCache.end())
+ return *it;
+
// Ensure the checksum type is in the db
if (!_insertChecksumTypeQuery.initOrReset(QByteArrayLiteral("INSERT OR IGNORE INTO checksumtype (name) VALUES (?1)"), _db))
return 0;
qCWarning(lcDb) << "No checksum type mapping found for" << checksumType;
return 0;
}
- return _getChecksumTypeIdQuery.intValue(0);
+ auto value = _getChecksumTypeIdQuery.intValue(0);
+ _checksymTypeCache[checksumType] = value;
+ return value;
}
QByteArray SyncJournalDb::dataFingerprint()
SqlDatabase _db;
QString _dbFile;
QMutex _mutex; // Public functions are protected with the mutex.
+ QMap<QByteArray, int> _checksymTypeCache;
int _transaction;
bool _metadataTableIsEmpty;