summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-12-29 22:45:30 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-12-29 22:45:30 +0100
commit7cfb7dcea4ab9249714bccd57124e07ec221b991 (patch)
treeec78c3a44ad2602a1ffa7dc4c6e48a6f43157f2e
parentPrevent copies when querying theme (diff)
downloadnheko-7cfb7dcea4ab9249714bccd57124e07ec221b991.tar.xz
Reduce allocations for presence states a bit
-rw-r--r--src/timeline/TimelineViewManager.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp

index effd0136..70a1510a 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -128,10 +128,17 @@ QString TimelineViewManager::userPresence(QString id) const { if (id.isEmpty()) - return QString(); + return {}; else - return QString::fromStdString( - mtx::presence::to_string(cache::presenceState(id.toStdString()))); + switch (cache::presenceState(id.toStdString())) { + case mtx::presence::PresenceState::offline: + return QStringLiteral("offline"); + case mtx::presence::PresenceState::unavailable: + return QStringLiteral("unavailable"); + case mtx::presence::PresenceState::online: + default: + return QStringLiteral("online"); + } } QString