Use QHash instead of QMap
authorKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 18 Jun 2020 13:15:25 +0000 (15:15 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 30 Jun 2020 09:29:08 +0000 (11:29 +0200)
This is not only a question of performances in our case (complexity
being better on look ups). It also provides a few more services.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/clientsideencryption.cpp
src/libsync/clientsideencryption.h
src/libsync/clientsideencryptionjobs.cpp
src/libsync/clientsideencryptionjobs.h

index f1e690efb10bda3f6434c7a3be332a3ad79c4faf..45b356b1ebc7a8888b2ff4350ebe6f2abbb57298 100644 (file)
@@ -1223,7 +1223,7 @@ void ClientSideEncryption::fetchFolderEncryptedStatus() {
     getEncryptedStatus->start();
 }
 
-void ClientSideEncryption::folderEncryptedStatusFetched(const QMap<QString, bool>& result)
+void ClientSideEncryption::folderEncryptedStatusFetched(const QHash<QString, bool>& result)
 {
     _refreshingEncryptionStatus = false;
     _folder2encryptedStatus = result;
index 7d9ce5fce51d9e0a1fd66b5388e0e37fb129c7e3..17f48348d513d68da97a1bf046f02ff4906e2451 100644 (file)
@@ -94,7 +94,7 @@ public slots:
     void slotRequestMnemonic();
 
 private slots:
-    void folderEncryptedStatusFetched(const QMap<QString, bool> &values);
+    void folderEncryptedStatusFetched(const QHash<QString, bool> &values);
     void folderEncryptedStatusError(int error);
 
     void publicKeyFetched(QKeychain::Job *incoming);
@@ -122,8 +122,8 @@ private:
     bool isInitialized = false;
     bool _refreshingEncryptionStatus = false;
     //TODO: Save this on disk.
-    QMap<QByteArray, QByteArray> _folder2token;
-    QMap<QString, bool> _folder2encryptedStatus;
+    QHash<QByteArray, QByteArray> _folder2token;
+    QHash<QString, bool> _folder2encryptedStatus;
 
 public:
     //QSslKey _privateKey;
index 7076124137908d21ee7200f727f107a604a8637b..afd7df08df5b597bab0eae5fd6a5b0ea776caf74 100644 (file)
@@ -77,7 +77,7 @@ bool GetFolderEncryptStatusJob::finished()
 
         QString currFile;
         int currEncryptedStatus = -1;
-        QMap<QString, bool> folderStatus;
+        QHash<QString, bool> folderStatus;
         while (!reader.atEnd()) {
             auto type = reader.readNext();
             if (type == QXmlStreamReader::StartElement) {
index 8831f7483b974c7d16e66d575c215c2c6b0264a7..9a375ff92ef29e139129468d72252c6fe459e627 100644 (file)
@@ -293,7 +293,7 @@ protected:
        bool finished() override;
 
 signals:
-       void encryptStatusReceived(const QMap<QString, bool> folderMetadata2EncryptionStatus);
+    void encryptStatusReceived(const QHash<QString, bool> folderMetadata2EncryptionStatus);
     void encryptStatusFolderReceived(const QString &folder, bool isEncrypted);
        void encryptStatusError(int statusCode);
 private: