From 52cab4b11bdd48cd87e04c01b12c698ec4145e6d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 15 Nov 2020 21:51:51 +0100 Subject: 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) --- lib/room.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/room.cpp') 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> keepContentKeysMap { + std::vector> 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(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(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; -- cgit v1.2.3