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

@@ -172,6 +172,10 @@ void UserListModel::refreshAllMembers()
{
beginResetModel();
if (m_currentRoom != nullptr) {
// Only sort members when this model needs to be refreshed.
if (m_currentRoom->sortedMemberIds().isEmpty()) {
m_currentRoom->sortAllMembers();
}
m_members = m_currentRoom->sortedMemberIds();
} else {
m_members.clear();