Use emplace_back for CFriendItem

This commit is contained in:
Robert Müller 2022-05-24 21:20:04 +02:00 committed by heinrich5991
parent 476af1286d
commit de1de5e7bd
2 changed files with 7 additions and 6 deletions

View file

@ -448,6 +448,12 @@ protected:
const CFriendInfo *m_pFriendInfo;
int m_NumFound;
CFriendItem() {}
CFriendItem(const CFriendInfo *pFriendInfo) :
m_pFriendInfo(pFriendInfo), m_NumFound(0)
{
}
bool operator<(const CFriendItem &Other) const
{
if(m_NumFound && !Other.m_NumFound)

View file

@ -1250,12 +1250,7 @@ void CMenus::FriendlistOnUpdate()
{
m_lFriends.clear();
for(int i = 0; i < m_pClient->Friends()->NumFriends(); ++i)
{
CFriendItem Item;
Item.m_pFriendInfo = m_pClient->Friends()->GetFriend(i);
Item.m_NumFound = 0;
m_lFriends.push_back(Item);
}
m_lFriends.emplace_back(m_pClient->Friends()->GetFriend(i));
std::sort(m_lFriends.begin(), m_lFriends.end());
}