Skip to content

Commit

Permalink
Replace 'push*' -> 'emplace*' if possible and use std::move()
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek authored and ge0rdi committed May 12, 2022
1 parent 4f36276 commit a20215d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Src/Lib/LanguageSettingsHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ LRESULT CLanguageSettingsDlg::OnSelChange( int idCtrl, LPNMHDR pnmh, BOOL& bHand
CComVariant val(name);
if (m_pSetting->value!=val)
SetSettingsDirty();
m_pSetting->value=val;
m_pSetting->value=std::move(val);

if (_wcsicmp(m_pSetting->value.bstrVal,m_pSetting->defValue.bstrVal)==0)
m_pSetting->flags|=CSetting::FLAG_DEFAULT;
Expand Down
4 changes: 2 additions & 2 deletions Src/Lib/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ CString CSettingsManager::LoadSettingsXml( const wchar_t *fname )
}
CComPtr<IXMLDOMNode> next;
child2->get_nextSibling(&next);
child2=next;
child2=std::move(next);
}
string.push_back(0);
pSetting->value=CComVariant(&string[0]);
Expand Down Expand Up @@ -839,7 +839,7 @@ CString CSettingsManager::LoadSettingsXml( const wchar_t *fname )
CComPtr<IXMLDOMNode> next;
if (child->get_nextSibling(&next)!=S_OK)
break;
child=next;
child=std::move(next);
}
if (ver<0x03090000)
UpgradeSettings(false);
Expand Down
2 changes: 1 addition & 1 deletion Src/Lib/SettingsUIHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ HRESULT STDMETHODCALLTYPE CBrowseLinkEvents::OnButtonClicked( IFileDialogCustomi
{
pfd->GetFolder(&pItem);
}
m_pResult=pItem;
m_pResult=std::move(pItem);
pfd->Close(S_FALSE);
return S_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Setup/Utility/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ static BOOL CALLBACK EnumResLangProc( HMODULE hModule, LPCTSTR lpszType, LPCTSTR
if (IS_INTRESOURCE(lpszName))
{
std::vector<std::pair<int,WORD>> &oldStrings=*(std::vector<std::pair<int,WORD>>*)lParam;
oldStrings.push_back(std::pair<int,WORD>(PtrToInt(lpszName),wIDLanguage));
oldStrings.emplace_back(PtrToInt(lpszName),wIDLanguage);
}
return TRUE;
}
Expand Down
30 changes: 15 additions & 15 deletions Src/StartMenu/StartMenuDLL/ItemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@ void CItemManager::Init( void )
{
int width, height;
pList->GetIconSize(&width,&height);
m_ListSizes.push_back(std::pair<int,int>(width,i));
m_ListSizes.emplace_back(width,i);
}
}
std::sort(m_ListSizes.begin(),m_ListSizes.end());

CreateDefaultIcons();
LoadCacheFile();

ItemInfo &item=m_ItemInfos.insert(std::pair<unsigned int,ItemInfo>(0,ItemInfo()))->second;
ItemInfo &item=m_ItemInfos.emplace(0,ItemInfo())->second;
item.bIconOnly=true;
item.smallIcon=m_DefaultSmallIcon;
item.largeIcon=m_DefaultLargeIcon;
Expand Down Expand Up @@ -704,21 +704,21 @@ void CItemManager::CreateDefaultIcons( void )
icon.bitmap=BitmapFromIcon(LoadShellIcon(index,SMALL_ICON_SIZE),SMALL_ICON_SIZE);
else
icon.bitmap=NULL;
m_DefaultSmallIcon=&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(0,icon))->second;
m_DefaultSmallIcon=&m_IconInfos.emplace(0,icon)->second;

icon.sizeType=ICON_SIZE_TYPE_LARGE;
if (index>=0)
icon.bitmap=BitmapFromIcon(LoadShellIcon(index,LARGE_ICON_SIZE),LARGE_ICON_SIZE);
else
icon.bitmap=NULL;
m_DefaultLargeIcon=&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(0,icon))->second;
m_DefaultLargeIcon=&m_IconInfos.emplace(0,icon)->second;

icon.sizeType=ICON_SIZE_TYPE_EXTRA_LARGE;
if (index>=0)
icon.bitmap=BitmapFromIcon(LoadShellIcon(index,EXTRA_LARGE_ICON_SIZE),EXTRA_LARGE_ICON_SIZE);
else
icon.bitmap=NULL;
m_DefaultExtraLargeIcon=&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(0,icon))->second;
m_DefaultExtraLargeIcon=&m_IconInfos.emplace(0,icon)->second;
}

CItemManager::LoadIconData &CItemManager::GetLoadIconData( void )
Expand Down Expand Up @@ -896,7 +896,7 @@ const CItemManager::ItemInfo *CItemManager::GetItemInfo( IShellItem *pItem, PIDL
}
if (!pInfo)
{
pInfo=&m_ItemInfos.insert(std::pair<unsigned int,ItemInfo>(hash,ItemInfo()))->second;
pInfo=&m_ItemInfos.emplace(hash,ItemInfo())->second;
pInfo->pidl.Clone(pidl);
pInfo->path=path;
pInfo->PATH=PATH;
Expand Down Expand Up @@ -978,7 +978,7 @@ const CItemManager::ItemInfo *CItemManager::GetItemInfo( CString path, int refre
}
if (!pInfo)
{
pInfo=&m_ItemInfos.insert(std::pair<unsigned int,ItemInfo>(hash,ItemInfo()))->second;
pInfo=&m_ItemInfos.emplace(hash,ItemInfo())->second;
if (!PATH.IsEmpty())
MenuParseDisplayName(path,&pInfo->pidl,NULL,NULL);
if (pInfo->pidl)
Expand Down Expand Up @@ -1076,7 +1076,7 @@ const CItemManager::ItemInfo *CItemManager::GetCustomIcon( const wchar_t *locati
}
if (!pInfo)
{
pInfo=&m_ItemInfos.insert(std::pair<unsigned int,ItemInfo>(hash,ItemInfo()))->second;
pInfo=&m_ItemInfos.emplace(hash,ItemInfo())->second;
pInfo->bIconOnly=true;
pInfo->bTemp=bTemp;
pInfo->iconPath=location;
Expand Down Expand Up @@ -1907,7 +1907,7 @@ void CItemManager::RefreshItemInfo( ItemInfo *pInfo, int refreshFlags, IShellIte
if (SUCCEEDED(store->GetValue(PKEY_MetroAppLauncher, &val)) && (val.vt == VT_I4 || val.vt == VT_UI4) && val.intVal)
{
newInfo.bLink = false;
pItem = target;
pItem = std::move(target);
pStore = store;
}
PropVariantClear(&val);
Expand Down Expand Up @@ -2597,7 +2597,7 @@ void CItemManager::StoreInCache( unsigned int hash, const wchar_t *path, HBITMAP

if ((refreshFlags&INFO_SMALL_ICON) && hSmallBitmap)
{
IconInfo *pInfo=&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(hash,IconInfo()))->second;
IconInfo *pInfo=&m_IconInfos.emplace(hash,IconInfo())->second;
pInfo->sizeType=ICON_SIZE_TYPE_SMALL;
pInfo->bTemp=bTemp;
pInfo->bMetro=bMetro;
Expand All @@ -2607,7 +2607,7 @@ void CItemManager::StoreInCache( unsigned int hash, const wchar_t *path, HBITMAP
}
if ((refreshFlags&INFO_LARGE_ICON) && hLargeBitmap)
{
IconInfo *pInfo=&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(hash,IconInfo()))->second;
IconInfo *pInfo=&m_IconInfos.emplace(hash,IconInfo())->second;
pInfo->sizeType=ICON_SIZE_TYPE_LARGE;
pInfo->bTemp=bTemp;
pInfo->bMetro=bMetro;
Expand All @@ -2617,7 +2617,7 @@ void CItemManager::StoreInCache( unsigned int hash, const wchar_t *path, HBITMAP
}
if ((refreshFlags&INFO_EXTRA_LARGE_ICON) && hExtraLargeBitmap)
{
IconInfo *pInfo=&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(hash,IconInfo()))->second;
IconInfo *pInfo=&m_IconInfos.emplace(hash,IconInfo())->second;
pInfo->sizeType=ICON_SIZE_TYPE_EXTRA_LARGE;
pInfo->bTemp=bTemp;
pInfo->bMetro=bMetro;
Expand Down Expand Up @@ -3273,7 +3273,7 @@ void CItemManager::LoadCacheFile( void )
bError=true;
break;
}
remapIcons.push_back(&m_IconInfos.insert(std::pair<unsigned int,IconInfo>(data.key,info))->second);
remapIcons.push_back(&m_IconInfos.emplace(data.key,info)->second);
}
else
{
Expand Down Expand Up @@ -3304,7 +3304,7 @@ void CItemManager::LoadCacheFile( void )
bError=true;
break;
}
ItemInfo &info=m_ItemInfos.insert(std::pair<unsigned int,ItemInfo>(data.key,ItemInfo()))->second;
ItemInfo &info=m_ItemInfos.emplace(data.key,ItemInfo())->second;

info.writestamp=data.writestamp;
info.createstamp=data.createstamp;
Expand Down Expand Up @@ -3568,7 +3568,7 @@ void CItemManager::ClearCache( void )
m_IconInfos.clear();
m_MetroItemInfos10.clear();
CreateDefaultIcons();
ItemInfo &item=m_ItemInfos.insert(std::pair<unsigned int,ItemInfo>(0,ItemInfo()))->second;
ItemInfo &item=m_ItemInfos.emplace(0,ItemInfo())->second;
item.bIconOnly=true;
item.smallIcon=m_DefaultSmallIcon;
item.largeIcon=m_DefaultLargeIcon;
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuDLL/MenuContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ void CMenuContainer::AddJumpListItems( std::vector<MenuItem> &items )
{
ILFree(item.pItem1);
item.pItem1=pidl2.Detach();
pItem=pItem2;
pItem=std::move(pItem2);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuDLL/SearchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ bool CSearchManager::SearchScope::ParseSearchConnector( const wchar_t *fname )
CComPtr<IXMLDOMNode> pNext;
if (pScopeItem->get_nextSibling(&pNext)!=S_OK)
break;
pScopeItem=pNext;
pScopeItem=std::move(pNext);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuDLL/SkinManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ bool MenuSkin::LoadSkin( HMODULE hMod, const wchar_t *variation, const wchar_t *
var.label=token;
if (var.labelEn.IsEmpty())
var.labelEn=var.label;
Variations.push_back(std::pair<int,Variation>(res,var));
Variations.emplace_back(res,var);
LOG_MENU(LOG_OPEN,L"Variation found: name=%s, id=%d",token,res);
}
else
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuHelper/ModernSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static std::vector<uint8_t> ParseModernSettings()
CComPtr<IXMLDOMNode> next;
if (FAILED(node->get_nextSibling(&next)))
break;
node = next;
node = std::move(next);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace DesktopNotificationManagerCompat
DesktopNotificationHistoryCompat::DesktopNotificationHistoryCompat(const wchar_t *aumid, ComPtr<IToastNotificationHistory> history)
{
m_aumid = std::wstring(aumid);
m_history = history;
m_history = std::move(history);
}

HRESULT DesktopNotificationHistoryCompat::Clear()
Expand Down

0 comments on commit a20215d

Please sign in to comment.