Make member list sorted a bit more efficient

I don't have any hard numbers on what difference this makes, but it's
definitely a positive improvement. I noticed and fixed a few issues that
were made more glaring by recent changes in libQuotient:

1. Room::memberJoined is called during the historical loading or
whatever, when we only need that *after* stuff is settled.
2. We really don't need to sort the room's members immediately - it's
only relevant when UserListModel is used (and I think this was previous
behavior?) So now its done lazily.
3. We do not want to call Room::effectivePowerLevel willy-nilly. It may
become a more expensive lookup, and it's also varying levels of wasteful
depending on which sorting algorithm the STL uses. It doesn't cost much
for us to keep a temporary cache for the lambda function to use.
This commit is contained in:
Joshua Goins
2026-02-12 18:43:05 -05:00
parent d47a4eb0de
commit 3d07f723c8
3 changed files with 34 additions and 9 deletions

View File

@@ -683,6 +683,8 @@ public:
/**
* @return List of members in this room, sorted by power level and then by name.
*
* This list is only populated after sortAllMembers() is called.
*/
QList<QString> sortedMemberIds() const;
@@ -721,6 +723,13 @@ public:
*/
Q_INVOKABLE void clearSelectedMessages();
/**
* @brief Sort all members based on their display name, and power level.
*
* @note This is a very expensive operation, and should only be done when truly needed.
*/
void sortAllMembers();
private:
bool m_visible = false;
@@ -767,8 +776,6 @@ private Q_SLOTS:
void invalidateLastUnreadHighlightId(const QString &fromEventId, const QString &toEventId);
void refreshAllMembers();
void insertMemberSorted(Quotient::RoomMember member);
Q_SIGNALS: