4 Commits

Author SHA1 Message Date
Let's All Love Lain
47cc2b2304 Replacing 'scopeList' contiguous placement of elements in memory more efficient and std::make_unique c++17
Signed-off-by: germanaizek <GermanAizek@yandex.ru>
2022-05-12 20:54:42 +02:00
germanaizek
a20215d9da Replace 'push*' -> 'emplace*' if possible and use std::move() 2022-05-12 20:54:42 +02:00
germanaizek
4f362760b6 Remove unused vars, usage '= default;' and fixed lower scope 2022-05-12 20:54:42 +02:00
Ibuprophen
2e43d4c7a1 Update README.md 2022-05-10 11:05:42 -04:00
17 changed files with 36 additions and 43 deletions

View File

@@ -24,7 +24,7 @@ If you just want to use it or looking for setup file, click here to download:
1. Download [language DLL](https://coddec.github.io/Classic-Shell/www.classicshell.net/translations/index.html)
2. Place it either in the Open-Shell's __install folder__ or in the `%ALLUSERSPROFILE%\OpenShell\Languages` folder
---
----
*For archival reasons, we have a mirror of `www.classicshell.net` [here](https://coddec.github.io/Classic-Shell/www.classicshell.net/).*

View File

@@ -195,9 +195,10 @@ static TDownloadResult DownloadFile( const wchar_t *url, std::vector<char> &buf,
{
if (pProgress && pProgress->IsCanceled())
res=DOWNLOAD_CANCEL;
const wchar_t *accept[]={L"*/*",NULL};
if (res==DOWNLOAD_OK)
{
const wchar_t* accept[] = { L"*/*",NULL };
HINTERNET hRequest=HttpOpenRequest(hConnect,L"GET",file,NULL,NULL,accept,((components.nScheme==INTERNET_SCHEME_HTTPS)?INTERNET_FLAG_SECURE:0)|(bAcceptCached?0:INTERNET_FLAG_RELOAD),0);
if (hRequest)
{

View File

@@ -127,7 +127,6 @@ VersionData CLanguageSettingsDlg::s_VersionData;
void CLanguageSettingsDlg::AddFlag( const wchar_t *langName, int langId, HBITMAP bmp )
{
std::vector<LangInfo>::iterator it=m_LanguageIDs.begin()+1;
int idx=1;
for (;idx<(int)m_LanguageIDs.size();idx++)
{
@@ -205,8 +204,6 @@ void CLanguageSettingsDlg::UpdateFlags( void )
DoEnvironmentSubst(path,_countof(path));
}
CWindow list=GetDlgItem(IDC_LISTLANGUAGE);
wchar_t find[_MAX_PATH];
Sprintf(find,_countof(find),L"%s\\*.dll",path);
WIN32_FIND_DATA data;
@@ -408,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;

View File

@@ -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]);
@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -16,9 +16,7 @@ CMenuAccessible::CMenuAccessible( CMenuContainer *pOwner )
CreateStdAccessibleObject(pOwner->m_hWnd,OBJID_CLIENT,IID_IAccessible,(void**)&m_pStdAccessible);
}
CMenuAccessible::~CMenuAccessible( void )
{
}
CMenuAccessible::~CMenuAccessible( void ) = default;
void CMenuAccessible::Reset( void )
{

View File

@@ -15,9 +15,7 @@ public:
m_RefCount=0;
}
~CDropTargetProxy( void )
{
}
~CDropTargetProxy( void ) = default;
void Reset( void )
{

View File

@@ -609,7 +609,7 @@ 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());
@@ -617,7 +617,7 @@ void CItemManager::Init( void )
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;
@@ -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 )
@@ -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;
@@ -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)
@@ -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;
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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
{
@@ -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;
@@ -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;

View File

@@ -2237,7 +2237,7 @@ void CMenuContainer::AddJumpListItems( std::vector<MenuItem> &items )
{
ILFree(item.pItem1);
item.pItem1=pidl2.Detach();
pItem=pItem2;
pItem=std::move(pItem2);
}
}
}

View File

@@ -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;
}
@@ -798,7 +798,7 @@ void CSearchManager::SearchThread( void )
CSession session;
if (SUCCEEDED(dataSource.OpenFromInitializationString(L"provider=Search.CollatorDSO.1;EXTENDED PROPERTIES=\"Application=Windows\"")) && SUCCEEDED(session.Open(dataSource)))
{
std::list<SearchScope> scopeList;
std::vector<SearchScope> scopeList;
if (searchRequest.bSearchMetroSettings && !m_bMetroSettingsFound)
{
@@ -1104,7 +1104,7 @@ void CSearchManager::SearchThread( void )
command0.Close();
continue;
}
for (std::list<SearchScope>::iterator it=scopeList.begin();it!=scopeList.end();++it)
for (auto it=scopeList.begin();it!=scopeList.end();++it)
{
if (it->roots.empty())
continue;
@@ -1122,7 +1122,7 @@ void CSearchManager::SearchThread( void )
else
{
len+=Strcpy(query+len,_countof(query)-len,L" AND System.Search.Store='FILE' AND System.ItemType!='.settingcontent-ms'");
for (std::list<SearchScope>::iterator it2=scopeList.begin();it2!=it;++it2)
for (auto it2=scopeList.begin();it2!=it;++it2)
{
if (it2->categoryHash==CATEGORY_METROSETTING)
continue;

View File

@@ -36,7 +36,7 @@ public:
struct SearchCategory
{
SearchCategory( void ) {}
SearchCategory( void ) = default;
SearchCategory( const SearchCategory &cat )
{
search.Clone(cat.search);

View File

@@ -3155,7 +3155,6 @@ LRESULT CCustomMenuDlg7::CItemList::OnSelEndOk( WORD wNotifyCode, WORD wID, HWND
if (m_Column==2)
{
// state
CString str;
menuItem.settings&=~CEditMenuDlg7::SETTINGS_MASK;
if (sel==0)
menuItem.settings|=StdMenuItem::MENU_ITEM_DISABLED;

View File

@@ -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

View File

@@ -3760,7 +3760,6 @@ if (!g_bTrimHooks)
// context menu
if (msg->message==WM_NCRBUTTONUP || msg->message==WM_RBUTTONUP)
{
CPoint pt0(GetMessagePos());
TaskbarInfo *taskBar=FindTaskBarInfoButton(msg->hwnd);
DWORD winVer=GetWinVersion();
if (!taskBar && winVer>=WIN_VER_WIN8)
@@ -3771,6 +3770,7 @@ if (!g_bTrimHooks)
}
if (taskBar)
{
CPoint pt0(GetMessagePos());
if (msg->message==WM_RBUTTONUP && msg->hwnd==taskBar->startButton && msg->lParam==MAKELPARAM(-1,-1))
{
RECT rc;

View File

@@ -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);
}
}
}

View File

@@ -168,7 +168,7 @@ namespace DesktopNotificationManagerCompat
ComPtr<IToastNotificationHistory> nativeHistory;
RETURN_IF_FAILED(toastStatics2->get_History(&nativeHistory));
*history = std::unique_ptr<DesktopNotificationHistoryCompat>(new DesktopNotificationHistoryCompat(s_aumid.c_str(), nativeHistory));
*history = std::make_unique<DesktopNotificationHistoryCompat>(s_aumid.c_str(), nativeHistory);
return S_OK;
}
@@ -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()