mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Avoid some copies when sorting the room list
This commit is contained in:
parent
ebd12a6f33
commit
264a85b9e4
2 changed files with 6 additions and 4 deletions
|
@ -217,4 +217,6 @@ private:
|
||||||
|
|
||||||
QColor bubbleBgColor_;
|
QColor bubbleBgColor_;
|
||||||
QColor bubbleFgColor_;
|
QColor bubbleFgColor_;
|
||||||
|
|
||||||
|
friend struct room_sort;
|
||||||
};
|
};
|
||||||
|
|
|
@ -353,8 +353,8 @@ RoomList::updateRoomDescription(const QString &roomid, const DescInfo &info)
|
||||||
|
|
||||||
struct room_sort
|
struct room_sort
|
||||||
{
|
{
|
||||||
bool operator()(const QSharedPointer<RoomInfoListItem> a,
|
bool operator()(const QSharedPointer<RoomInfoListItem> &a,
|
||||||
const QSharedPointer<RoomInfoListItem> b) const
|
const QSharedPointer<RoomInfoListItem> &b) const
|
||||||
{
|
{
|
||||||
// Sort by "importance" (i.e. invites before mentions before
|
// Sort by "importance" (i.e. invites before mentions before
|
||||||
// notifs before new events before old events), then secondly
|
// notifs before new events before old events), then secondly
|
||||||
|
@ -370,9 +370,9 @@ struct room_sort
|
||||||
// Now sort by recency
|
// Now sort by recency
|
||||||
// Zero if empty, otherwise the time that the event occured
|
// Zero if empty, otherwise the time that the event occured
|
||||||
const uint64_t a_recency =
|
const uint64_t a_recency =
|
||||||
a->lastMessageInfo().userid.isEmpty() ? 0 : a->lastMessageInfo().timestamp;
|
a->lastMsgInfo_.userid.isEmpty() ? 0 : a->lastMsgInfo_.timestamp;
|
||||||
const uint64_t b_recency =
|
const uint64_t b_recency =
|
||||||
b->lastMessageInfo().userid.isEmpty() ? 0 : b->lastMessageInfo().timestamp;
|
b->lastMsgInfo_.userid.isEmpty() ? 0 : b->lastMsgInfo_.timestamp;
|
||||||
return a_recency > b_recency;
|
return a_recency > b_recency;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue