summary refs log tree commit diff
path: root/src/timeline/RoomlistModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-12-29 06:01:38 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-12-29 06:01:38 +0100
commit19dc6cadea0168f72daff7c0ed679ccdac71a7d5 (patch)
treeb10a86fcd0ab0f12f5e242996b307bb2cac97940 /src/timeline/RoomlistModel.cpp
parentReduce allocations required for the palette (diff)
downloadnheko-19dc6cadea0168f72daff7c0ed679ccdac71a7d5.tar.xz
Reserve size of some containers we are filling
Diffstat (limited to 'src/timeline/RoomlistModel.cpp')
-rw-r--r--src/timeline/RoomlistModel.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp

index 0757d27e..2dfe5d6f 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp
@@ -90,6 +90,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const if (role == Roles::ParentSpaces) { auto parents = cache::client()->getParentRoomIds(roomid.toStdString()); QStringList list; + list.reserve(static_cast<int>(parents.size())); for (const auto &t : parents) list.push_back(QString::fromStdString(t)); return list; @@ -98,7 +99,8 @@ RoomlistModel::data(const QModelIndex &index, int role) const } else if (role == Roles::IsDirect) { return directChatToUser.count(roomid) > 0; } else if (role == Roles::DirectChatOtherUserId) { - return directChatToUser.count(roomid) ? directChatToUser.at(roomid).front() : QLatin1String(""); + return directChatToUser.count(roomid) ? directChatToUser.at(roomid).front() + : QLatin1String(""); } if (models.contains(roomid)) { @@ -113,7 +115,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const case Roles::Time: return room->lastMessage().descriptiveTime; case Roles::Timestamp: - return QVariant(static_cast<quint64>(room->lastMessage().timestamp)); + return QVariant{static_cast<quint64>(room->lastMessage().timestamp)}; case Roles::HasUnreadMessages: return this->roomReadStatus.count(roomid) && this->roomReadStatus.at(roomid); case Roles::HasLoudNotification: @@ -129,6 +131,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const case Roles::Tags: { auto info = cache::singleRoomInfo(roomid.toStdString()); QStringList list; + list.reserve(static_cast<int>(info.tags.size())); for (const auto &t : info.tags) list.push_back(QString::fromStdString(t)); return list; @@ -148,7 +151,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const case Roles::Time: return QString(); case Roles::Timestamp: - return QVariant(static_cast<quint64>(0)); + return QVariant{static_cast<quint64>(0)}; case Roles::HasUnreadMessages: case Roles::HasLoudNotification: return false; @@ -177,7 +180,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const case Roles::Time: return QString(); case Roles::Timestamp: - return QVariant(static_cast<quint64>(0)); + return QVariant{static_cast<quint64>(0)}; case Roles::HasUnreadMessages: case Roles::HasLoudNotification: return false;