summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-10-31 00:47:12 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2023-10-31 13:04:39 +0100
commit4357c47ebe11552844d2479a74f15f1927f4d038 (patch)
treee4f7d4f9de5660c59a64c1f230b8b10d6eeeb90e /src/timeline
parentSave appveyor cache on failure (diff)
downloadnheko-4357c47ebe11552844d2479a74f15f1927f4d038.tar.xz
A few more small speedups
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/EventStore.cpp3
-rw-r--r--src/timeline/TimelineModel.cpp55
2 files changed, 3 insertions, 55 deletions
diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp
index 04e548f0..de109b1a 100644
--- a/src/timeline/EventStore.cpp
+++ b/src/timeline/EventStore.cpp
@@ -509,8 +509,7 @@ EventStore::handleSync(const mtx::responses::Timeline &events)
               std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) {
             auto d_event = decryptEvent({room_id_, encrypted->event_id}, *encrypted);
             if (d_event->event &&
-                std::visit([](auto e) { return (e.sender != utils::localUser().toStdString()); },
-                           *d_event->event)) {
+                mtx::accessors::sender(*d_event->event) != utils::localUser().toStdString()) {
                 handle_room_verification(this, *d_event->event);
             }
         }
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 490641a6..f4f2361c 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -260,8 +260,7 @@ toRoomEventType(const mtx::events::collections::TimelineEvents &event)
 QString
 toRoomEventTypeString(const mtx::events::collections::TimelineEvents &event)
 {
-    return std::visit([](const auto &e) { return QString::fromStdString(to_string(e.type)); },
-                      event);
+    return QString::fromStdString(to_string(mtx::accessors::event_type(event)));
 }
 
 mtx::events::EventType
@@ -1271,56 +1270,6 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
     updateLastMessage();
 }
 
-template<typename T>
-static constexpr auto
-isMessage(const mtx::events::RoomEvent<T> &e)
-  -> std::enable_if_t<std::is_same<decltype(e.content.msgtype), std::string>::value, bool>
-{
-    return true;
-}
-
-template<typename T>
-static constexpr auto
-isMessage(const mtx::events::Event<T> &)
-{
-    return false;
-}
-
-template<typename T>
-static constexpr auto
-isMessage(const mtx::events::EncryptedEvent<T> &)
-{
-    return true;
-}
-
-static constexpr auto
-isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallInvite> &)
-{
-    return true;
-}
-
-static constexpr auto
-isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallAnswer> &)
-{
-    return true;
-}
-static constexpr auto
-isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &)
-{
-    return true;
-}
-
-static constexpr auto
-isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallReject> &)
-{
-    return true;
-}
-static constexpr auto
-isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallSelectAnswer> &)
-{
-    return true;
-}
-
 // Workaround. We also want to see a room at the top, if we just joined it
 auto
 isYourJoin(const mtx::events::StateEvent<mtx::events::state::Member> &e, EventStore &events)
@@ -1385,7 +1334,7 @@ TimelineModel::updateLastMessage()
             }
             return;
         }
-        if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, *event))
+        if (!mtx::accessors::is_message(*event))
             continue;
 
         auto description = utils::getMessageDescription(