aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-14 14:06:14 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-16 17:58:17 +0100
commit2178ca994c4b33197239155f7f6715e0451b9172 (patch)
treed5f7e92fee9f94cf6a23507c8d9da08cc1501885 /lib
parent445e34f26450cf8262a65b74e1294579d9cd56be (diff)
downloadlibquotient-2178ca994c4b33197239155f7f6715e0451b9172.tar.gz
libquotient-2178ca994c4b33197239155f7f6715e0451b9172.zip
Use QHash instead of QMap
We don't seem to need sorted associative containers in those cases.
Diffstat (limited to 'lib')
-rw-r--r--lib/e2ee/e2ee.h4
-rw-r--r--lib/e2ee/qolmaccount.cpp16
-rw-r--r--lib/e2ee/qolmaccount.h2
3 files changed, 7 insertions, 15 deletions
diff --git a/lib/e2ee/e2ee.h b/lib/e2ee/e2ee.h
index e21aa87b..361c48ff 100644
--- a/lib/e2ee/e2ee.h
+++ b/lib/e2ee/e2ee.h
@@ -55,10 +55,10 @@ struct IdentityKeys
//! Struct representing the one-time keys.
struct QUOTIENT_API OneTimeKeys
{
- QMap<QString, QMap<QString, QString>> keys;
+ QHash<QString, QHash<QString, QString>> keys;
//! Get the HashMap containing the curve25519 one-time keys.
- QMap<QString, QString> curve25519() const;
+ QHash<QString, QString> curve25519() const;
//! Get a reference to the hashmap corresponding to given key type.
// std::optional<QHash<QString, QString>> get(QString keyType) const;
diff --git a/lib/e2ee/qolmaccount.cpp b/lib/e2ee/qolmaccount.cpp
index 9cbb14f5..476a60bd 100644
--- a/lib/e2ee/qolmaccount.cpp
+++ b/lib/e2ee/qolmaccount.cpp
@@ -14,7 +14,7 @@
using namespace Quotient;
-QMap<QString, QString> OneTimeKeys::curve25519() const
+QHash<QString, QString> OneTimeKeys::curve25519() const
{
return keys[Curve25519Key];
}
@@ -164,21 +164,13 @@ OneTimeKeys QOlmAccount::oneTimeKeys() const
}
const auto json = QJsonDocument::fromJson(oneTimeKeysBuffer).object();
OneTimeKeys oneTimeKeys;
-
- for (const QString& key1 : json.keys()) {
- auto oneTimeKeyObject = json[key1].toObject();
- auto keyMap = QMap<QString, QString>();
- for (const QString &key2 : oneTimeKeyObject.keys()) {
- keyMap[key2] = oneTimeKeyObject[key2].toString();
- }
- oneTimeKeys.keys[key1] = keyMap;
- }
+ fromJson(json, oneTimeKeys.keys);
return oneTimeKeys;
}
-QMap<QString, SignedOneTimeKey> QOlmAccount::signOneTimeKeys(const OneTimeKeys &keys) const
+QHash<QString, SignedOneTimeKey> QOlmAccount::signOneTimeKeys(const OneTimeKeys &keys) const
{
- QMap<QString, SignedOneTimeKey> signedOneTimeKeys;
+ QHash<QString, SignedOneTimeKey> signedOneTimeKeys;
for (const auto &keyid : keys.curve25519().keys()) {
const auto oneTimeKey = keys.curve25519()[keyid];
QByteArray sign = signOneTimeKey(oneTimeKey);
diff --git a/lib/e2ee/qolmaccount.h b/lib/e2ee/qolmaccount.h
index 17aca8aa..17f43f1a 100644
--- a/lib/e2ee/qolmaccount.h
+++ b/lib/e2ee/qolmaccount.h
@@ -67,7 +67,7 @@ public:
OneTimeKeys oneTimeKeys() const;
//! Sign all one time keys.
- QMap<QString, SignedOneTimeKey> signOneTimeKeys(const OneTimeKeys &keys) const;
+ QHash<QString, SignedOneTimeKey> signOneTimeKeys(const OneTimeKeys &keys) const;
//! Sign one time key.
QByteArray signOneTimeKey(const QString &key) const;