aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-11-15 21:51:51 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-11-15 21:51:51 +0100
commit52cab4b11bdd48cd87e04c01b12c698ec4145e6d (patch)
treef8b44dd9c585606b4ac229c396ef914d5950fd47 /lib/room.cpp
parent5b1bfc102fccd4e57893b34bf2b0a14ba6a9f577 (diff)
downloadlibquotient-52cab4b11bdd48cd87e04c01b12c698ec4145e6d.tar.gz
libquotient-52cab4b11bdd48cd87e04c01b12c698ec4145e6d.zip
Cleanup across event classes
In particular: removed unnecessary #includes, deprecated and no more used constructs, replaced stored members with dynamic generation from JSON (TypingEvent and, especially promising for performance, ReceiptEvent)
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 3b5a80a4..7ac3463e 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -2073,7 +2073,7 @@ RoomEventPtr makeRedacted(const RoomEvent& target,
QStringLiteral("membership") };
// clang-format on
- std::vector<std::pair<Event::Type, QStringList>> keepContentKeysMap {
+ std::vector<std::pair<event_type_t, QStringList>> keepContentKeysMap {
{ RoomMemberEvent::typeId(), { QStringLiteral("membership") } },
{ RoomCreateEvent::typeId(), { QStringLiteral("creator") } },
{ RoomPowerLevelsEvent::typeId(),
@@ -2621,7 +2621,7 @@ Room::Changes Room::processEphemeralEvent(EventPtr&& event)
et.start();
if (auto* evt = eventCast<TypingEvent>(event)) {
d->usersTyping.clear();
- for (const QString& userId : qAsConst(evt->users())) {
+ for (const auto& userId : evt->users()) {
auto u = user(userId);
if (memberJoinState(u) == JoinState::Join)
d->usersTyping.append(u);
@@ -2633,7 +2633,8 @@ Room::Changes Room::processEphemeralEvent(EventPtr&& event)
}
if (auto* evt = eventCast<ReceiptEvent>(event)) {
int totalReceipts = 0;
- for (const auto& p : qAsConst(evt->eventsWithReceipts())) {
+ const auto& eventsWithReceipts = evt->eventsWithReceipts();
+ for (const auto& p : eventsWithReceipts) {
totalReceipts += p.receipts.size();
{
if (p.receipts.size() == 1)
@@ -2669,11 +2670,11 @@ Room::Changes Room::processEphemeralEvent(EventPtr&& event)
}
}
}
- if (evt->eventsWithReceipts().size() > 3 || totalReceipts > 10
+ if (eventsWithReceipts.size() > 3 || totalReceipts > 10
|| et.nsecsElapsed() >= profilerMinNsecs())
qCDebug(PROFILER)
<< "*** Room::processEphemeralEvent(receipts):"
- << evt->eventsWithReceipts().size() << "event(s) with"
+ << eventsWithReceipts.size() << "event(s) with"
<< totalReceipts << "receipt(s)," << et;
}
return changes;