mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
fix(Core): do not use map[] to test presence of element, [] create an item if not exist
This commit is contained in:
parent
43a62dc84a
commit
13182409bf
1 changed files with 7 additions and 5 deletions
|
|
@ -106,12 +106,14 @@ shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom (const strin
|
|||
|
||||
void CorePrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom) {
|
||||
L_ASSERT(chatRoom);
|
||||
L_ASSERT(!chatRoomsById[chatRoom->getChatRoomId()]
|
||||
|| (chatRoomsById[chatRoom->getChatRoomId()] == chatRoom)
|
||||
);
|
||||
if (!chatRoomsById[chatRoom->getChatRoomId()]) {
|
||||
|
||||
const ChatRoomId &chatRoomId = chatRoom->getChatRoomId();
|
||||
auto it = chatRoomsById.find(chatRoomId);
|
||||
// Chat room not exist or yes but with the same pointer!
|
||||
L_ASSERT(it == chatRoomsById.end() || it->second == chatRoom);
|
||||
if (it == chatRoomsById.end()) {
|
||||
chatRooms.push_back(chatRoom);
|
||||
chatRoomsById[chatRoom->getChatRoomId()] = chatRoom;
|
||||
chatRoomsById[chatRoomId] = chatRoom;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue