diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-02-23 14:42:33 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-02-23 14:42:33 +0900 |
commit | c82198c9d35a2a91a7440851b6e7d7a71f662c68 (patch) | |
tree | 90cb9301f289c6ea97b784c8d35a28427b9245d9 /events/receiptevent.h | |
parent | 0a653e0e1c6c050f54df12663539cdb2e02717d8 (diff) | |
download | libquotient-c82198c9d35a2a91a7440851b6e7d7a71f662c68.tar.gz libquotient-c82198c9d35a2a91a7440851b6e7d7a71f662c68.zip |
Receipts internal handling improved
Instead of QHash, use QVector< QPair<> > because it's more efficient and
we don't really need a hashmap functions, only direct iteration over the
list of event-to-receipt pairs. Also, iteration over QJsonObjects is
more efficient (and better conveys the intention) than collecting keys()
and then finding a value() for each of them. Also, fixed accidental
allocation of empty Receipt structures instead of reserving space for
them.
Diffstat (limited to 'events/receiptevent.h')
-rw-r--r-- | events/receiptevent.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/events/receiptevent.h b/events/receiptevent.h index 5ca33f75..a7e1debf 100644 --- a/events/receiptevent.h +++ b/events/receiptevent.h @@ -36,6 +36,7 @@ Q_DECLARE_TYPEINFO(QMatrixClient::Receipt, Q_MOVABLE_TYPE); namespace QMatrixClient { using Receipts = QVector<Receipt>; + using EventsToReceipts = QVector< QPair<QString, Receipts> >; class ReceiptEvent: public Event { @@ -43,9 +44,7 @@ namespace QMatrixClient ReceiptEvent(); virtual ~ReceiptEvent(); - Receipts receiptsForEvent(QString eventId) const; - - QStringList events() const; + EventsToReceipts events() const; static ReceiptEvent* fromJson(const QJsonObject& obj); |