Changeset View
Changeset View
Standalone View
Standalone View
src/matrix-room-list.cpp
| Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | , m_roomIds(lager::with(m_tagIdCursor, m_client.rooms(), m_filter, m_client.roomIdsByTagId(), m_userGivenNicknameMap) | ||||
| std::sort( | std::sort( | ||||
| container.begin(), | container.begin(), | ||||
| container.end(), | container.end(), | ||||
| [allRooms](const std::string &idA, const std::string &idB) { | [allRooms](const std::string &idA, const std::string &idB) { | ||||
| const auto &roomA = allRooms[idA]; | const auto &roomA = allRooms[idA]; | ||||
| const auto &roomB = allRooms[idB]; | const auto &roomB = allRooms[idB]; | ||||
| auto aIsInvite = roomA.membership == Invite; | auto aIsInvite = roomA.membership == Invite; | ||||
| auto bIsInvite = roomB.membership == Invite; | auto bIsInvite = roomB.membership == Invite; | ||||
| auto aIsFavourite = roomA.tags().count("m.favourite") == 1; | |||||
| auto bIsFavourite = roomB.tags().count("m.favourite") == 1; | |||||
| if (aIsInvite != bIsInvite) { | if (aIsInvite != bIsInvite) { | ||||
tusooa: Use `count()` not `find()` | |||||
Done Inline ActionsWhy? The complexity of both of them is O(1). nannanko: Why? The complexity of both of them is O(1). | |||||
Done Inline ActionsBecause you don't need a pointer... tusooa: Because you don't need a pointer... | |||||
| /** | /** | ||||
| * if my membership in A is invite, | * if my membership in A is invite, | ||||
| * then the membership in B is not invite, | * then the membership in B is not invite, | ||||
| * so A should come first; | * so A should come first; | ||||
Done Inline ActionsInvitations should still be put on the very top tusooa: Invitations should still be put on the very top | |||||
| * otherwise B should come first | * otherwise B should come first | ||||
| **/ | **/ | ||||
| return aIsInvite; | return aIsInvite; | ||||
| } else if (aIsFavourite != bIsFavourite) { | |||||
| return aIsFavourite; | |||||
| } else { | } else { | ||||
| return latestEventTimestamp(roomA) | return latestEventTimestamp(roomA) | ||||
| > latestEventTimestamp(roomB); | > latestEventTimestamp(roomB); | ||||
| } | } | ||||
| } | } | ||||
| ); | ); | ||||
| return immer::flex_vector<std::string>(container.begin(), container.end()); | return immer::flex_vector<std::string>(container.begin(), container.end()); | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines | |||||
Use count() not find()