From de1de5e7bd358f9290bea67ddb8b86ac617b53c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 24 May 2022 21:20:04 +0200 Subject: [PATCH] Use emplace_back for CFriendItem --- src/game/client/components/menus.h | 6 ++++++ src/game/client/components/menus_browser.cpp | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index b4cfa64e7..1482e07a0 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -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) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 6495a24e6..244c90d2a 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -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()); }