diff --git a/ShellExtension/Common/WinMergeContextMenu.cpp b/ShellExtension/Common/WinMergeContextMenu.cpp index 05a39750686..a0603fdfd14 100644 --- a/ShellExtension/Common/WinMergeContextMenu.cpp +++ b/ShellExtension/Common/WinMergeContextMenu.cpp @@ -174,6 +174,7 @@ bool WinMergeContextMenu::UpdateMenuState(const std::vector& paths std::vector WinMergeContextMenu::GetMenuItemList() const { std::vector list; + list.reserve(3); bool isdir = m_strPaths.empty() ? false : !!PathIsDirectory(m_strPaths[0].c_str()); bool enabled = (m_strPaths.size() <= MaxFileCount); int icon = isdir ? IDI_WINMERGEDIR : IDI_WINMERGE; diff --git a/Src/7zCommon.cpp b/Src/7zCommon.cpp index 0335c4c966f..a202b85bf7f 100644 --- a/Src/7zCommon.cpp +++ b/Src/7zCommon.cpp @@ -706,7 +706,8 @@ DecompressResult DecompressArchive(HWND hWnd, const PathContext& files) if (!PathFileExists(res.files[0].c_str()) || !PathFileExists(res.files[1].c_str())) { // not a Perry style patch: diff with itself... - res.files[0] = res.files[1] = path; + res.files[0] = path; + res.files[1] = std::move(path); } else { diff --git a/Src/AboutDlg.cpp b/Src/AboutDlg.cpp index eec5365a690..e65c1d232db 100644 --- a/Src/AboutDlg.cpp +++ b/Src/AboutDlg.cpp @@ -170,5 +170,5 @@ void CAboutDlg::Impl::OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult) } CAboutDlg::CAboutDlg() : m_pimpl(new CAboutDlg::Impl(this)) {} -CAboutDlg::~CAboutDlg() {} +CAboutDlg::~CAboutDlg() = default; int CAboutDlg::DoModal() { return static_cast(m_pimpl->DoModal()); } diff --git a/Src/Common/BCMenu.cpp b/Src/Common/BCMenu.cpp index 3f542554688..78d27175f80 100644 --- a/Src/Common/BCMenu.cpp +++ b/Src/Common/BCMenu.cpp @@ -55,9 +55,7 @@ HTHEME BCMenu::m_hTheme = nullptr; static class GdiplusToken { public: - GdiplusToken() - { - } + GdiplusToken() = default; ~GdiplusToken() { @@ -1715,7 +1713,7 @@ bool BCMenu::DeleteMenu(UINT uiId,UINT nFlags) INT_PTR menulistsize=m_MenuList.GetSize(); if(uiId<(UINT)menulistsize){ CString str=m_MenuList[uiId]->GetString(); - if(str==""){ + if(str.IsEmpty()){ delete m_MenuList.GetAt(uiId); m_MenuList.RemoveAt(uiId); } diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index ed3732e718e..e42135f8974 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -605,7 +605,7 @@ void CMDITabBar::UpdateToolTips(int nTabItemIndex) strTooltip = pITabBar ? pITabBar->GetTooltipString() : _T(""); if (strTooltip == strTitle && strTitle.GetLength() <= GetMaxTitleLength()) - strTooltip = ""; + strTooltip.Empty(); m_tooltips.UpdateTipText(strTooltip, this); CRect rc; diff --git a/Src/Common/OptionsMgr.cpp b/Src/Common/OptionsMgr.cpp index 77bef7257ad..f1b0af40123 100644 --- a/Src/Common/OptionsMgr.cpp +++ b/Src/Common/OptionsMgr.cpp @@ -41,9 +41,7 @@ varprop::VariantValue COptionsMgr::m_emptyValue; /** * @brief Default constructor. */ -COption::COption() -{ -} +COption::COption() = default; /** * @brief Copy constructor. diff --git a/Src/Common/PreferencesDlg.cpp b/Src/Common/PreferencesDlg.cpp index c75f116e954..8653dcfd405 100644 --- a/Src/Common/PreferencesDlg.cpp +++ b/Src/Common/PreferencesDlg.cpp @@ -185,10 +185,9 @@ void CPreferencesDlg::AddPage(CPropertyPage* pPage, UINT nTopHeading, UINT nSubH void CPreferencesDlg::AddPage(CPropertyPage* pPage, LPCTSTR szPath) { - CString sPath(szPath); - if (m_pphost.AddPage(pPage)) { + CString sPath(szPath); HTREEITEM htiParent = TVI_ROOT; // default int nFind = sPath.Find(PATHDELIM); diff --git a/Src/Common/RegOptionsMgr.cpp b/Src/Common/RegOptionsMgr.cpp index 7bd2bc7be79..745fbb4b4dc 100644 --- a/Src/Common/RegOptionsMgr.cpp +++ b/Src/Common/RegOptionsMgr.cpp @@ -523,7 +523,7 @@ int CRegOptionsMgr::SetRegRootKey(const String& key) if (ind != 0) keyname.insert(0, _T("Software\\")); - m_registryRoot = keyname; + m_registryRoot = std::move(keyname); LONG retValReg = RegCreateKeyEx(HKEY_CURRENT_USER, m_registryRoot.c_str(), 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &hKey, &action); diff --git a/Src/Common/ShellContextMenu.cpp b/Src/Common/ShellContextMenu.cpp index 84287310f3a..bf1ee907dfa 100644 --- a/Src/Common/ShellContextMenu.cpp +++ b/Src/Common/ShellContextMenu.cpp @@ -209,8 +209,8 @@ bool CShellContextMenu::QueryShellContextMenu() return false; } - m_pShellContextMenu2 = pCMenu2; - m_pShellContextMenu3 = pCMenu3; + m_pShellContextMenu2 = std::move(pCMenu2); + m_pShellContextMenu3 = std::move(pCMenu3); return true; } diff --git a/Src/Common/SplitterWndEx.cpp b/Src/Common/SplitterWndEx.cpp index 3b306b447a2..4e41e2cd11b 100644 --- a/Src/Common/SplitterWndEx.cpp +++ b/Src/Common/SplitterWndEx.cpp @@ -449,9 +449,9 @@ static COLORREF GetIntermediateColor(COLORREF a, COLORREF b, float ratio) void CSplitterWndEx::OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg) { - CRect rect = rectArg; if (nType == splitBorder && pDC != nullptr && !m_bHideBorders) { + CRect rect = rectArg; COLORREF clrShadow = GetSysColor(COLOR_BTNSHADOW); COLORREF clrFace = GetSysColor(COLOR_BTNFACE); COLORREF clrShadow2 = GetIntermediateColor(clrFace, clrShadow, 0.9f); diff --git a/Src/Common/SuperComboBox.cpp b/Src/Common/SuperComboBox.cpp index 9fcef279afb..db6751e3b6c 100644 --- a/Src/Common/SuperComboBox.cpp +++ b/Src/Common/SuperComboBox.cpp @@ -460,7 +460,7 @@ void CSuperComboBox::ResetContent() m_sFullStateText.resize(m_nMaxItems); for (int i = 0; i < m_nMaxItems; i++) { - m_sFullStateText[i] = _T(""); + m_sFullStateText[i].Empty(); } } CComboBoxEx::ResetContent(); diff --git a/Src/Common/lwdisp.c b/Src/Common/lwdisp.c index df1776e47cf..3c2e35ec3da 100644 --- a/Src/Common/lwdisp.c +++ b/Src/Common/lwdisp.c @@ -310,7 +310,8 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCWSTR progid) mycpyt2w(_T("script:"), wc, DIMOF(wc)); else mycpyt2w(_T(""), wc, DIMOF(wc)); - mycpyt2w(source, wc+wcslen(wc), DIMOF(wc)-wcslen(wc)); + size_t len = wcslen(wc); + mycpyt2w(source, wc + len, DIMOF(wc) - len); // I observed that CoGetObject() may internally provoke an access // violation and succeed anyway. No idea how to avoid this. diff --git a/Src/Common/multiformatText.cpp b/Src/Common/multiformatText.cpp index b474f41b584..30c3350a3fa 100644 --- a/Src/Common/multiformatText.cpp +++ b/Src/Common/multiformatText.cpp @@ -100,7 +100,7 @@ const TCHAR *storageForPlugins::GetDestFileName() try { TFile(m_tempFilenameDst).renameTo(tempFilenameDstNew); - m_tempFilenameDst = tempFilenameDstNew; + m_tempFilenameDst = std::move(tempFilenameDstNew); } catch (Exception& e) { diff --git a/Src/Common/scbarcf.cpp b/Src/Common/scbarcf.cpp index 3d1a8c03852..0b547b5f05f 100644 --- a/Src/Common/scbarcf.cpp +++ b/Src/Common/scbarcf.cpp @@ -86,7 +86,7 @@ void CSizingControlBarCF::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHnd SendMessage(WM_NCPAINT); } -void CSizingControlBarCF::NcPaintGripper(CDC* pDC, CRect rcClient) +void CSizingControlBarCF::NcPaintGripper(CDC* pDC, const CRect& rcClient) { if (!HasGripper()) return; diff --git a/Src/Common/scbarcf.h b/Src/Common/scbarcf.h index 26d6eafc66c..587699bac38 100644 --- a/Src/Common/scbarcf.h +++ b/Src/Common/scbarcf.h @@ -50,7 +50,7 @@ class CSizingControlBarCF : public baseCSizingControlBarCF // Implementation protected: // implementation helpers - virtual void NcPaintGripper(CDC* pDC, CRect rcClient) override; + virtual void NcPaintGripper(CDC* pDC, const CRect& rcClient) override; protected: bool m_bActive; // a child has focus diff --git a/Src/Common/scbarg.cpp b/Src/Common/scbarg.cpp index d7d3bee4b51..1af9850093d 100644 --- a/Src/Common/scbarg.cpp +++ b/Src/Common/scbarg.cpp @@ -105,7 +105,7 @@ void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID) *pRc = rc; } -void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient) +void CSizingControlBarG::NcPaintGripper(CDC* pDC, const CRect& rcClient) { if (!HasGripper()) return; diff --git a/Src/Common/scbarg.h b/Src/Common/scbarg.h index 699295a7fa9..35bb17af3ca 100644 --- a/Src/Common/scbarg.h +++ b/Src/Common/scbarg.h @@ -90,7 +90,7 @@ class CSizingControlBarG : public baseCSizingControlBarG protected: // implementation helpers - virtual void NcPaintGripper(CDC* pDC, CRect rcClient) override; + virtual void NcPaintGripper(CDC* pDC, const CRect& rcClient) override; virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID) override; protected: diff --git a/Src/Common/sizecbar.cpp b/Src/Common/sizecbar.cpp index 40fb883b031..7cfb00487e7 100644 --- a/Src/Common/sizecbar.cpp +++ b/Src/Common/sizecbar.cpp @@ -530,7 +530,7 @@ void CSizingControlBar::OnNcPaint() mdc.SelectObject(pOldBm); } -void CSizingControlBar::NcPaintGripper(CDC* pDC, CRect rcClient) +void CSizingControlBar::NcPaintGripper(CDC* pDC, const CRect& rcClient) { UNUSED_ALWAYS(pDC); UNUSED_ALWAYS(rcClient); @@ -791,7 +791,7 @@ void CSizingControlBar::OnTrackInvertTracker() m_pDockSite->ReleaseDC(pDC); } -bool CSizingControlBar::GetEdgeRect(CRect rcWnd, UINT nHitTest, +bool CSizingControlBar::GetEdgeRect(const CRect& rcWnd, UINT nHitTest, CRect& rcEdge) { rcEdge = rcWnd; diff --git a/Src/Common/sizecbar.h b/Src/Common/sizecbar.h index c446df21431..a6adfaf94a9 100644 --- a/Src/Common/sizecbar.h +++ b/Src/Common/sizecbar.h @@ -122,12 +122,12 @@ class CSizingControlBar : public baseCSizingControlBar protected: // implementation helpers UINT GetEdgeHTCode(int nEdge); - bool GetEdgeRect(CRect rcWnd, UINT nHitTest, CRect& rcEdge); + bool GetEdgeRect(const CRect& rcWnd, UINT nHitTest, CRect& rcEdge); virtual void StartTracking(UINT nHitTest, CPoint point); virtual void StopTracking(); virtual void OnTrackUpdateSize(CPoint& point); virtual void OnTrackInvertTracker(); - virtual void NcPaintGripper(CDC* pDC, CRect rcClient); + virtual void NcPaintGripper(CDC* pDC, const CRect& rcClient); virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID); virtual void AlignControlBars(); diff --git a/Src/CompareEngines/BinaryCompare.cpp b/Src/CompareEngines/BinaryCompare.cpp index 20ce37a1e91..bae4d58c1f9 100644 --- a/Src/CompareEngines/BinaryCompare.cpp +++ b/Src/CompareEngines/BinaryCompare.cpp @@ -20,9 +20,7 @@ BinaryCompare::BinaryCompare() : m_piAbortable(nullptr) { } -BinaryCompare::~BinaryCompare() -{ -} +BinaryCompare::~BinaryCompare() = default; /** * @brief Set Abortable-interface. diff --git a/Src/CompareEngines/ByteCompare.cpp b/Src/CompareEngines/ByteCompare.cpp index ea77c803aa9..ddc48a2b891 100644 --- a/Src/CompareEngines/ByteCompare.cpp +++ b/Src/CompareEngines/ByteCompare.cpp @@ -39,9 +39,7 @@ ByteCompare::ByteCompare() /** * @brief Default destructor. */ -ByteCompare::~ByteCompare() -{ -} +ByteCompare::~ByteCompare() = default; /** * @brief Set compare options from general compare options. diff --git a/Src/CompareEngines/TimeSizeCompare.cpp b/Src/CompareEngines/TimeSizeCompare.cpp index 203ca071e20..2f0471b028c 100644 --- a/Src/CompareEngines/TimeSizeCompare.cpp +++ b/Src/CompareEngines/TimeSizeCompare.cpp @@ -20,9 +20,7 @@ TimeSizeCompare::TimeSizeCompare() { } -TimeSizeCompare::~TimeSizeCompare() -{ -} +TimeSizeCompare::~TimeSizeCompare() = default; /** * @brief Set compare-type specific options. diff --git a/Src/CompareStats.cpp b/Src/CompareStats.cpp index 14a5882a96d..5875eab9169 100644 --- a/Src/CompareStats.cpp +++ b/Src/CompareStats.cpp @@ -27,9 +27,7 @@ CompareStats::CompareStats(int nDirs) /** * @brief Destructor, deletes critical section. */ -CompareStats::~CompareStats() -{ -} +CompareStats::~CompareStats() = default; /** * @brief Add compared item. diff --git a/Src/ConfigLog.cpp b/Src/ConfigLog.cpp index b748367be49..593095145be 100644 --- a/Src/ConfigLog.cpp +++ b/Src/ConfigLog.cpp @@ -305,7 +305,7 @@ bool CConfigLog::DoFile(String &sError) text = GetWindowsVer(); FileWriteString(text); text = GetProcessorInfo(); - if (text != _T("")) + if (!text.empty()) { FileWriteString(_T("\r\n Processor: ")); FileWriteString(text); @@ -445,12 +445,12 @@ String CConfigLog::GetProcessorInfo() String sProductName = _T(""); if (key.QueryRegMachine(_T("Hardware\\Description\\System\\CentralProcessor\\0"))) sProductName = key.ReadString(_T("Identifier"), _T("")); - if (sProductName != _T("")) + if (!sProductName.empty()) { // This is the full identifier of the processor // (e.g. "Intel64 Family 6 Model 158 Stepping 9") // but we'll only keep the first word (e.g. "Intel64") - int x = (int)sProductName.find_first_of(_T(" ")); + int x = (int)sProductName.find_first_of(_T(' ')); sProductName = sProductName.substr(0, x); } diff --git a/Src/DiffContext.cpp b/Src/DiffContext.cpp index 0b9fed3d730..d4d12fdc3f0 100644 --- a/Src/DiffContext.cpp +++ b/Src/DiffContext.cpp @@ -67,9 +67,7 @@ CDiffContext::CDiffContext(const PathContext & paths, int compareMethod) /** * @brief Destructor. */ -CDiffContext::~CDiffContext() -{ -} +CDiffContext::~CDiffContext() = default; /** * @brief Update info in item in result list from disk. diff --git a/Src/DiffFileInfo.h b/Src/DiffFileInfo.h index d7063793529..185cb42350f 100644 --- a/Src/DiffFileInfo.h +++ b/Src/DiffFileInfo.h @@ -31,7 +31,7 @@ struct DiffFileInfo : public DirItem // methods - DiffFileInfo() { } + DiffFileInfo() = default; //void Clear(); void ClearPartial(); bool IsEditableEncoding() const; diff --git a/Src/DiffList.h b/Src/DiffList.h index 0f305147d7a..7a65dd547d7 100644 --- a/Src/DiffList.h +++ b/Src/DiffList.h @@ -53,9 +53,7 @@ struct DIFFRANGE int dend = 0; /**< Synchronised (ghost lines added) last diff line in file1,2,3 */ int blank[3] = {-1, -1, -1}; /**< Number of blank lines in file1,2,3 */ OP_TYPE op = OP_NONE; /**< Operation done with this diff */ - DIFFRANGE() - { - } + DIFFRANGE() = default; void swap_sides(int index1, int index2); }; @@ -75,7 +73,7 @@ class DiffMap std::vector m_map; - DiffMap() { } + DiffMap() = default; void InitDiffMap(int nlines); }; diff --git a/Src/DiffTextBuffer.cpp b/Src/DiffTextBuffer.cpp index e5d14fad638..0759d262e2b 100644 --- a/Src/DiffTextBuffer.cpp +++ b/Src/DiffTextBuffer.cpp @@ -490,7 +490,7 @@ int CDiffTextBuffer::SaveToFile (const String& pszFileName, sLine.append(GetLineChars(line), nLineLength); } else - sLine = _T(""); + sLine.clear(); if (bTempFile && m_bTableEditing && m_bAllowNewlinesInQuotes) { diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index 623ba2d5654..0b5a71cb661 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -87,9 +87,7 @@ CDiffWrapper::CDiffWrapper() /** * @brief Destructor. */ -CDiffWrapper::~CDiffWrapper() -{ -} +CDiffWrapper::~CDiffWrapper() = default; /** * @brief Enables/disables patch-file creation and sets filename. @@ -1476,7 +1474,7 @@ const SubstitutionList* CDiffWrapper::GetSubstitutionList() const void CDiffWrapper::SetSubstitutionList(std::shared_ptr pSubstitutionList) { - m_pSubstitutionList = pSubstitutionList; + m_pSubstitutionList = std::move(pSubstitutionList); } void CDiffWrapper::SetFilterCommentsSourceDef(const String& ext) diff --git a/Src/DiffWrapper.h b/Src/DiffWrapper.h index 7261906e1a1..a18b2662e7f 100644 --- a/Src/DiffWrapper.h +++ b/Src/DiffWrapper.h @@ -121,7 +121,7 @@ struct DIFFSTATUS IDENTLEVEL Identical = IDENTLEVEL::NONE; /**< diffutils said files are identical */ bool bPatchFileFailed = false; /**< Creating patch file failed */ - DIFFSTATUS() {} + DIFFSTATUS() = default; void MergeStatus(const DIFFSTATUS& other) { if (Identical == IDENTLEVEL::ALL) diff --git a/Src/DirActions.cpp b/Src/DirActions.cpp index 97639b92645..1d180475603 100644 --- a/Src/DirActions.cpp +++ b/Src/DirActions.cpp @@ -143,10 +143,10 @@ static void ThrowConfirmationNeededException(const CDiffContext& ctxt, const Str strDest = paths::AddTrailingSlash(dest); exp.m_question = question; - exp.m_fromText = sOrig; - exp.m_toText = sDest; - exp.m_fromPath = strSrc; - exp.m_toPath = strDest; + exp.m_fromText = std::move(sOrig); + exp.m_toText = std::move(sDest); + exp.m_fromPath = std::move(strSrc); + exp.m_toPath = std::move(strDest); throw exp; } diff --git a/Src/DirCmpReport.cpp b/Src/DirCmpReport.cpp index 2fcc0892aec..412bfbf1015 100644 --- a/Src/DirCmpReport.cpp +++ b/Src/DirCmpReport.cpp @@ -471,7 +471,7 @@ void DirCmpReport::GenerateXmlHtmlContent(bool xml) { String sFileName, sParentDir; paths::SplitFilename((const TCHAR *)m_pFile->GetFilePath(), &sParentDir, &sFileName, nullptr); - String sRelDestDir = sFileName.substr(0, sFileName.find_last_of(_T("."))) + _T(".files"); + String sRelDestDir = sFileName.substr(0, sFileName.find_last_of(_T('.'))) + _T(".files"); String sDestDir = paths::ConcatPath(sParentDir, sRelDestDir); if (!xml && m_bIncludeFileCmpReport && m_pFileCmpReport != nullptr) paths::CreateIfNeeded(sDestDir); diff --git a/Src/DirItemIterator.h b/Src/DirItemIterator.h index 239849b1d8b..debd1f27685 100644 --- a/Src/DirItemIterator.h +++ b/Src/DirItemIterator.h @@ -47,7 +47,7 @@ class DirItemWithIndexIterator : public std::iterator(m_pimpl->DoModal()); } diff --git a/Src/DirView.cpp b/Src/DirView.cpp index f91113bbf11..eea8f9d4952 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -957,7 +957,7 @@ void CDirView::DoDirActionTo(SIDE_TYPE stype, DirActions::method_type func, cons try { // First we build a list of desired actions FileActionScript actionScript; - actionScript.m_destBase = destPath; + actionScript.m_destBase = std::move(destPath); DirItemWithIndexIterator begin(m_pIList.get(), -1, true); DirItemWithIndexIterator end; FileActionScript *rsltScript; @@ -3112,7 +3112,7 @@ void CDirView::OnPluginSettings(UINT nID) { case ID_PREDIFFER_SETTINGS_NONE: case ID_UNPACKER_SETTINGS_NONE: - pluginPipeline = _T(""); + pluginPipeline.clear(); break; case ID_PREDIFFER_SETTINGS_AUTO: case ID_UNPACKER_SETTINGS_AUTO: @@ -4203,8 +4203,6 @@ void CDirView::OnSearch() */ void CDirView::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) { - COleDataSource *DropData = new COleDataSource(); - std::list list; CopyPathnamesForDragAndDrop(SelBegin(), SelEnd(), std::back_inserter(list), GetDiffContext()); String filesForDroping = strutils::join(list.begin(), list.end(), _T("\n")) + _T("\n"); @@ -4215,6 +4213,7 @@ void CDirView::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) HGLOBAL hMem = GlobalReAlloc(file.Detach(), (filesForDroping.length() + 1) * sizeof(TCHAR), 0); if (hMem != nullptr) { + COleDataSource* DropData = new COleDataSource(); DropData->CacheGlobalData(CF_UNICODETEXT, hMem); DROPEFFECT de = DropData->DoDragDrop(DROPEFFECT_COPY | DROPEFFECT_MOVE, nullptr); } diff --git a/Src/DirViewColItems.cpp b/Src/DirViewColItems.cpp index dcf701b818e..6e6ed331186 100644 --- a/Src/DirViewColItems.cpp +++ b/Src/DirViewColItems.cpp @@ -423,7 +423,7 @@ static String ColDiffsGet(const CDiffContext *, const void *p, int) } else if (r == CDiffContext::DIFFS_UNKNOWN) { // Unique item - s = _T(""); + s.clear(); } else { diff --git a/Src/DropHandler.cpp b/Src/DropHandler.cpp index 6315a59333d..5230879c59b 100644 --- a/Src/DropHandler.cpp +++ b/Src/DropHandler.cpp @@ -286,9 +286,7 @@ DropHandler::DropHandler(std::function&)> callbac { } -DropHandler::~DropHandler() -{ -} +DropHandler::~DropHandler() = default; HRESULT STDMETHODCALLTYPE DropHandler::QueryInterface(REFIID riid, void **ppvObject) { diff --git a/Src/Exceptions.h b/Src/Exceptions.h index aaaee78ea68..51761b76dd2 100644 --- a/Src/Exceptions.h +++ b/Src/Exceptions.h @@ -35,7 +35,7 @@ class SE_Exception unsigned long nSE; public: explicit SE_Exception(unsigned long n) : nSE(n) {} - ~SE_Exception() {}; + ~SE_Exception() = default; unsigned long getSeNumber() { return nSE; } #ifdef _MSC_VER diff --git a/Src/FileActionScript.cpp b/Src/FileActionScript.cpp index ff16b2af95e..b193ba15f8f 100644 --- a/Src/FileActionScript.cpp +++ b/Src/FileActionScript.cpp @@ -38,9 +38,7 @@ FileActionScript::FileActionScript() /** * @brief Standard destructor. */ -FileActionScript::~FileActionScript() -{ -} +FileActionScript::~FileActionScript() = default; /** * @brief Remove last action item from the list. diff --git a/Src/FileFilterHelper.cpp b/Src/FileFilterHelper.cpp index bddcb1822fb..5b09236246e 100644 --- a/Src/FileFilterHelper.cpp +++ b/Src/FileFilterHelper.cpp @@ -32,9 +32,7 @@ FileFilterHelper::FileFilterHelper() /** * @brief Destructor, deletes filtermanager. */ -FileFilterHelper::~FileFilterHelper() -{ -} +FileFilterHelper::~FileFilterHelper() = default; /** * @brief Store current filter path. diff --git a/Src/FileFilterMgr.cpp b/Src/FileFilterMgr.cpp index 3c3054b57f9..81a1df6e0a2 100644 --- a/Src/FileFilterMgr.cpp +++ b/Src/FileFilterMgr.cpp @@ -175,7 +175,7 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error paths::SplitFilename(szFilepath, nullptr, &fileName, nullptr); FileFilter *pfilter = new FileFilter; pfilter->fullpath = szFilepath; - pfilter->name = fileName; // Filename is the default name + pfilter->name = std::move(fileName); // Filename is the default name String sLine; bool lossy = false; @@ -185,7 +185,7 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error // Returns false when last line is read String tmpLine; bLinesLeft = file.ReadString(tmpLine, &lossy); - sLine = tmpLine; + sLine = std::move(tmpLine); sLine = strutils::trim_ws(sLine); if (0 == sLine.compare(0, 5, _T("name:"), 5)) @@ -194,7 +194,7 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error String str = sLine.substr(5); str = strutils::trim_ws_begin(str); if (!str.empty()) - pfilter->name = str; + pfilter->name = std::move(str); } else if (0 == sLine.compare(0, 5, _T("desc:"), 5)) { @@ -202,7 +202,7 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error String str = sLine.substr(5); str = strutils::trim_ws_begin(str); if (!str.empty()) - pfilter->description = str; + pfilter->description = std::move(str); } else if (0 == sLine.compare(0, 4, _T("def:"), 4)) { diff --git a/Src/FileFiltersDlg.cpp b/Src/FileFiltersDlg.cpp index efe9208d854..2b91227c829 100644 --- a/Src/FileFiltersDlg.cpp +++ b/Src/FileFiltersDlg.cpp @@ -440,7 +440,7 @@ void FileFiltersDlg::OnBnClickedFilterfileNewbutton() TCHAR dir[_MAX_DIR] = {0}; TCHAR drive[_MAX_DRIVE] = {0}; _tsplitpath_s(s.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, file, _MAX_FNAME, ext, _MAX_EXT); - if (_tcslen(ext) == 0) + if (ext[0] == '\0') { s += FileFilterExt; } @@ -570,11 +570,11 @@ void FileFiltersDlg::OnBnClickedFilterfileInstall() auto* pGlobalFileFilter = theApp.GetGlobalFileFilter(); String s; String path; - String userPath = pGlobalFileFilter->GetUserFilterPathWithCreate(); if (SelectFile(GetSafeHwnd(), s, true, path.c_str(),_("Locate filter file to install"), _("File Filters (*.flt)|*.flt|All Files (*.*)|*.*||"))) { + String userPath = pGlobalFileFilter->GetUserFilterPathWithCreate(); userPath = paths::ConcatPath(userPath, paths::FindFileName(s)); if (!CopyFile(s.c_str(), userPath.c_str(), TRUE)) { diff --git a/Src/FileLocation.h b/Src/FileLocation.h index 9b1f23d6d9e..4ee9f536ead 100644 --- a/Src/FileLocation.h +++ b/Src/FileLocation.h @@ -19,9 +19,7 @@ struct FileLocation /** * The default constructor. */ - FileLocation() - { - } + FileLocation() = default; /** * The constructor taking a path as a parameter. diff --git a/Src/FilterList.cpp b/Src/FilterList.cpp index 33d69f45ba8..598b41e06ed 100644 --- a/Src/FilterList.cpp +++ b/Src/FilterList.cpp @@ -15,9 +15,7 @@ using Poco::RegularExpression; /** * @brief Constructor. */ - FilterList::FilterList() -{ -} +FilterList::FilterList() = default; /** * @brief Destructor. diff --git a/Src/FolderCmp.cpp b/Src/FolderCmp.cpp index b5a8c2ed202..12e32c7234b 100644 --- a/Src/FolderCmp.cpp +++ b/Src/FolderCmp.cpp @@ -41,9 +41,7 @@ FolderCmp::FolderCmp(CDiffContext *pCtxt) { } -FolderCmp::~FolderCmp() -{ -} +FolderCmp::~FolderCmp() = default; bool FolderCmp::RunPlugins(PluginsContext * plugCtxt, String &errStr) { diff --git a/Src/GhostTextView.cpp b/Src/GhostTextView.cpp index d16f1832040..9a2e1113c11 100644 --- a/Src/GhostTextView.cpp +++ b/Src/GhostTextView.cpp @@ -211,14 +211,14 @@ void CGhostTextView::GetTextWithoutEmptys (int nStartLine, int nStartChar, if (m_pGhostTextBuffer != nullptr) m_pGhostTextBuffer->GetTextWithoutEmptys (nStartLine, nStartChar, nEndLine, nEndChar, text, nCrlfStyle, bExcludeInvisibleLines); else - text = _T (""); + text.Empty(); } void CGhostTextView::GetTextWithoutEmptysInColumnSelection (CString & text, bool bExcludeInvisibleLines /*= true*/) { if (m_pGhostTextBuffer == nullptr) { - text = _T (""); + text.Empty(); return; } diff --git a/Src/ImgMergeFrm.cpp b/Src/ImgMergeFrm.cpp index 6e7acd51f38..3788ed084b9 100644 --- a/Src/ImgMergeFrm.cpp +++ b/Src/ImgMergeFrm.cpp @@ -285,7 +285,7 @@ void CImgMergeFrame::ChangeFile(int nBuffer, const String& path) m_filePaths[nBuffer] = path; m_nBufferType[nBuffer] = BUFFERTYPE::NORMAL; - m_strDesc[nBuffer] = _T(""); + m_strDesc[nBuffer].clear(); int nActivePane = m_pImgMergeWindow->GetActivePane(); OpenImages(); @@ -1469,7 +1469,6 @@ LRESULT CImgMergeFrame::OnStorePaneSizes(WPARAM wParam, LPARAM lParam) void CImgMergeFrame::OnUpdateStatusNum(CCmdUI* pCmdUI) { - TCHAR sIdx[32] = { 0 }; TCHAR sCnt[32] = { 0 }; String s; const int nDiffs = m_pImgMergeWindow->GetDiffCount(); @@ -1491,6 +1490,7 @@ void CImgMergeFrame::OnUpdateStatusNum(CCmdUI* pCmdUI) // - show diff number and amount of diffs else { + TCHAR sIdx[32] = { 0 }; s = theApp.LoadString(IDS_DIFF_NUMBER_STATUS_FMT); const int signInd = m_pImgMergeWindow->GetCurrentDiffIndex(); _itot_s(signInd + 1, sIdx, 10); @@ -2309,7 +2309,6 @@ bool CImgMergeFrame::GenerateReport(const String& sFileName, bool allPages) cons void CImgMergeFrame::OnToolsGenerateReport() { String s; - CString folder; BOOL allPages = true; #if NTDDI_VERSION >= NTDDI_VISTA @@ -2322,6 +2321,7 @@ void CImgMergeFrame::OnToolsGenerateReport() dlg.GetCheckButtonState(1001, allPages); s = dlg.GetPathName(); #else + CString folder; if (!SelectFile(AfxGetMainWnd()->GetSafeHwnd(), s, false, folder, _T(""), _("HTML Files (*.htm,*.html)|*.htm;*.html|All Files (*.*)|*.*||"), _T("htm"))) return; #endif diff --git a/Src/InternalPlugins.cpp b/Src/InternalPlugins.cpp index 8a5085366ee..8dada8d7246 100644 --- a/Src/InternalPlugins.cpp +++ b/Src/InternalPlugins.cpp @@ -173,7 +173,7 @@ class XMLHandler : public Poco::XML::ContentHandler else if (localName == ExtendedPropertiesElement) plugin.m_extendedProperties = value; else if (localName == ArgumentsElement) - plugin.m_arguments = value; + plugin.m_arguments = std::move(value); } else if (localName == PrediffFileElement) { diff --git a/Src/LineFiltersList.cpp b/Src/LineFiltersList.cpp index f9c1a181b56..6929ef8ecf9 100644 --- a/Src/LineFiltersList.cpp +++ b/Src/LineFiltersList.cpp @@ -27,9 +27,7 @@ LineFiltersList::LineFiltersList() /** * @brief Destructor, empties the list. */ -LineFiltersList::~LineFiltersList() -{ -} +LineFiltersList::~LineFiltersList() = default; /** * @brief Add new filter to the list. diff --git a/Src/LocationView.cpp b/Src/LocationView.cpp index 174d38a13b4..aecdde5a11e 100644 --- a/Src/LocationView.cpp +++ b/Src/LocationView.cpp @@ -548,7 +548,6 @@ void CLocationView::DrawRect(CDC* pDC, const CRect& r, COLORREF cr, bool bSelect // Draw only colored blocks if (cr != CLR_NONE && cr != GetSysColor(COLOR_WINDOW)) { - CBrush brush(cr); CRect drawRect(r); drawRect.DeflateRect(1, 0); diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 3587116a5c3..f9eeab322cd 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -1628,9 +1628,9 @@ HexMergeDocList &CMainFrame::GetAllHexMergeDocs() return static_cast(GetDocList(theApp.m_pHexMergeTemplate)); } -std::list CMainFrame::GetAllImgMergeFrames() +std::vector CMainFrame::GetAllImgMergeFrames() { - std::list list; + std::vector list; // Close Non-Document/View frame with confirmation CMDIChildWnd *pChild = static_cast(CWnd::FromHandle(m_hWndMDIClient)->GetWindow(GW_CHILD)); while (pChild != nullptr) @@ -3141,7 +3141,7 @@ void CMainFrame::AppendPluginMenus(CMenu *pMenu, const String& filteredFilenames pMenu->AppendMenu(MF_STRING, ID_NOT_SUGGESTED_PLUGINS, _("All plugins").c_str()); } - std::vector processTypes; + std::list processTypes; for (const auto& [processType, pluginList] : allPlugins) processTypes.push_back(processType); auto it = std::find(processTypes.begin(), processTypes.end(), _("&Others")); @@ -3151,7 +3151,7 @@ void CMainFrame::AppendPluginMenus(CMenu *pMenu, const String& filteredFilenames processTypes.push_back(_("&Others")); } - for (const auto& processType: processTypes) + for (const auto& processType : processTypes) { CMenu popup; popup.CreatePopupMenu(); diff --git a/Src/MainFrm.h b/Src/MainFrm.h index e4e4c2355ba..a036bb4414b 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -384,7 +384,7 @@ class CMainFrame : public CMDIFrameWnd MergeDocList &GetAllMergeDocs(); DirDocList &GetAllDirDocs(); HexMergeDocList &GetAllHexMergeDocs(); - std::list GetAllImgMergeFrames(); + std::vector GetAllImgMergeFrames(); void UpdateFont(FRAMETYPE frame); BOOL CreateToolbar(); CMergeEditView * GetActiveMergeEditView(); diff --git a/Src/Merge.cpp b/Src/Merge.cpp index 5bb8cb2a067..c0b1268170f 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -999,7 +999,7 @@ bool CMergeApp::CreateBackup(bool bFolder, const String& pszPath) PropBackups::FOLDER_ORIGINAL) { // Put backups to same folder than original file - bakPath = path; + bakPath = std::move(path); } else if (GetOptionsMgr()->GetInt(OPT_BACKUP_LOCATION) == PropBackups::FOLDER_GLOBAL) @@ -1007,7 +1007,7 @@ bool CMergeApp::CreateBackup(bool bFolder, const String& pszPath) // Put backups to global folder defined in options bakPath = GetOptionsMgr()->GetString(OPT_BACKUP_GLOBALFOLDER); if (bakPath.empty()) - bakPath = path; + bakPath = std::move(path); else bakPath = paths::GetLongPath(bakPath); } @@ -1093,7 +1093,6 @@ int CMergeApp::HandleReadonlySave(String& strSavePath, bool bMultiFile, bool bFileExists = false; String s; String str; - CString title; if (!strSavePath.empty()) { diff --git a/Src/MergeCmdLineInfo.cpp b/Src/MergeCmdLineInfo.cpp index 464f2830724..152622b0d03 100644 --- a/Src/MergeCmdLineInfo.cpp +++ b/Src/MergeCmdLineInfo.cpp @@ -250,7 +250,7 @@ void MergeCmdLineInfo::ParseWinMergeCmdLine(const TCHAR *q) else if (param == _T("image")) m_nWindowType = WindowType::IMAGE; else - m_sErrorMessages.push_back(_T("Unknown window type '") + param + _T("' specified")); + m_sErrorMessages.emplace_back(_T("Unknown window type '") + param + _T("' specified")); } else if (param == _T("m")) { @@ -274,7 +274,7 @@ void MergeCmdLineInfo::ParseWinMergeCmdLine(const TCHAR *q) else if (param == _T("size")) m_nCompMethod = CompareMethodType::SIZE; else - m_sErrorMessages.push_back(_T("Unknown compare method '") + param + _T("' specified")); + m_sErrorMessages.emplace_back(_T("Unknown compare method '") + param + _T("' specified")); } else if (param == _T("r")) { @@ -527,7 +527,7 @@ void MergeCmdLineInfo::ParseWinMergeCmdLine(const TCHAR *q) } else { - m_sErrorMessages.push_back(_T("Unknown option '/") + param + _T("'")); + m_sErrorMessages.emplace_back(_T("Unknown option '/") + param + _T("'")); } } // If "compare file dir" make it "compare file dir\file". diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index f2f9931cfd7..1dd47654c31 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -1195,7 +1195,7 @@ void CMergeDoc::DoAutoMerge(int dstPane) * @param [in] dr Difference to check. * @return true if difference lines match, false otherwise. */ -bool CMergeDoc::SanityCheckDiff(DIFFRANGE dr) const +bool CMergeDoc::SanityCheckDiff(const DIFFRANGE& dr) const { const int cd_dbegin = dr.dbegin; const int cd_dend = dr.dend; @@ -1626,7 +1626,7 @@ bool CMergeDoc::TrySaveAs(String &strPath, int &nSaveResult, String & sError, if (SelectFile(GetActiveMergeView()->GetSafeHwnd(), s, false, strPath.c_str(), title)) { CDiffTextBuffer *pBuffer = m_ptBuf[nBuffer].get(); - strSavePath = s; + strSavePath = std::move(s); nSaveResult = pBuffer->SaveToFile(strSavePath, false, sError, infoTempUnpacker); @@ -1774,9 +1774,9 @@ bool CMergeDoc::DoSave(LPCTSTR szPath, bool &bSaveSuccess, int nBuffer) } m_ptBuf[nBuffer]->SetModified(false); - m_pSaveFileInfo[nBuffer]->Update(strSavePath.c_str()); - m_filePaths[nBuffer] = strSavePath; - m_pRescanFileInfo[nBuffer]->Update(m_filePaths[nBuffer].c_str()); + m_pSaveFileInfo[nBuffer]->Update(strSavePath); + m_filePaths[nBuffer] = std::move(strSavePath); + m_pRescanFileInfo[nBuffer]->Update(m_filePaths[nBuffer]); UpdateHeaderPath(nBuffer); bSaveSuccess = true; result = true; @@ -1837,7 +1837,7 @@ bool CMergeDoc::DoSaveAs(LPCTSTR szPath, bool &bSaveSuccess, int nBuffer) if (nSaveErrorCode == SAVE_DONE) { m_pSaveFileInfo[nBuffer]->Update(strSavePath); - m_filePaths[nBuffer] = strSavePath; + m_filePaths[nBuffer] = std::move(strSavePath); m_pRescanFileInfo[nBuffer]->Update(m_filePaths[nBuffer]); UpdateHeaderPath(nBuffer); bSaveSuccess = true; @@ -2241,7 +2241,6 @@ void CMergeDoc::OnUpdateStatusRO(CCmdUI* pCmdUI) */ void CMergeDoc::OnUpdateStatusNum(CCmdUI* pCmdUI) { - TCHAR sIdx[32] = { 0 }; TCHAR sCnt[32] = { 0 }; String s; const int nDiffs = m_diffList.GetSignificantDiffs(); @@ -2263,6 +2262,7 @@ void CMergeDoc::OnUpdateStatusNum(CCmdUI* pCmdUI) // - show diff number and amount of diffs else { + TCHAR sIdx[32] = { 0 }; s = _("Difference %1 of %2"); const int signInd = m_diffList.GetSignificantIndex(GetCurrentDiff()); _itot_s(signInd + 1, sIdx, 10); @@ -2927,7 +2927,7 @@ void CMergeDoc::SanityCheckCodepage(FileLocation & fileinfo) * @param [in] encoding File's encoding. * @return One of FileLoadResult values. */ -DWORD CMergeDoc::LoadOneFile(int index, String filename, bool readOnly, const String& strDesc, +DWORD CMergeDoc::LoadOneFile(int index, const String& filename, bool readOnly, const String& strDesc, const FileTextEncoding & encoding) { DWORD loadSuccess = FileLoadResult::FRESULT_ERROR;; @@ -3374,18 +3374,20 @@ void CMergeDoc::ChangeFile(int nBuffer, const String& path, int nLineIndex) } std::copy_n(m_strDesc, m_nBuffers, strDesc); - strDesc[nBuffer] = _T(""); + strDesc[nBuffer].clear(); fileloc[nBuffer].setPath(path); fileloc[nBuffer].encoding = codepage_detect::Guess(path, GetOptionsMgr()->GetInt(OPT_CP_DETECT)); bool filenameChanged = path != m_filePaths[nBuffer]; - auto columnWidths = m_ptBuf[nBuffer]->GetColumnWidths(); int nActivePane = GetActiveMergeView()->m_nThisPane; if (OpenDocs(m_nBuffers, fileloc, bRO, strDesc)) { if (!filenameChanged) + { + auto columnWidths = m_ptBuf[nBuffer]->GetColumnWidths(); m_ptBuf[nBuffer]->SetColumnWidths(columnWidths); + } MoveOnLoad(nActivePane, nLineIndex); } } @@ -3613,11 +3615,11 @@ void CMergeDoc::OnFileReload() fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage(); fileloc[pane].setPath(m_filePaths[pane]); } - int nActivePane = GetActiveMergeView()->m_nThisPane; - CPoint pt = GetActiveMergeView()->GetCursorPos(); - auto columnWidths = m_ptBuf[0]->GetColumnWidths(); if (OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc)) { + CPoint pt = GetActiveMergeView()->GetCursorPos(); + auto columnWidths = m_ptBuf[0]->GetColumnWidths(); + int nActivePane = GetActiveMergeView()->m_nThisPane; m_ptBuf[0]->SetColumnWidths(columnWidths); MoveOnLoad(nActivePane, pt.y); } diff --git a/Src/MergeDoc.h b/Src/MergeDoc.h index 95e447dcf96..d8b55297f1a 100644 --- a/Src/MergeDoc.h +++ b/Src/MergeDoc.h @@ -167,7 +167,7 @@ class CMergeDoc : public CDocument, public IMergeDoc void CopyMultipleList(int srcPane, int dstPane, int firstDiff, int lastDiff, int firstWordDiff = -1, int lastWordDiff = -1); void CopyMultiplePartialList(int srcPane, int dstPane, int firstDiff, int lastDiff, int firstLineDiff = -1, int lastLineDiff = -1); void DoAutoMerge(int dstPane); - bool SanityCheckDiff(DIFFRANGE dr) const; + bool SanityCheckDiff(const DIFFRANGE& dr) const; bool WordListCopy(int srcPane, int dstPane, int nDiff, int nFirstWordDiff, int nLastWordDiff, const std::vector *pWordDiffIndice, bool bGroupWithPrevious = false, bool bUpdateView = true); bool PartialListCopy(int srcPane, int dstPane, int nDiff, int firstLine, int lastLine = -1, bool bGroupWithPrevious = false, bool bUpdateView = true); bool ListCopy(int srcPane, int dstPane, int nDiff = -1, bool bGroupWithPrevious = false, bool bUpdateView = true); @@ -330,7 +330,7 @@ class CMergeDoc : public CDocument, public IMergeDoc bool GetByteColoringOption() const; bool IsValidCodepageForMergeEditor(unsigned cp) const; void SanityCheckCodepage(FileLocation & fileinfo); - DWORD LoadOneFile(int index, String filename, bool readOnly, const String& strDesc, const FileTextEncoding & encoding); + DWORD LoadOneFile(int index, const String& filename, bool readOnly, const String& strDesc, const FileTextEncoding & encoding); void SetTableProperties(); // Implementation data diff --git a/Src/MergeEditView.cpp b/Src/MergeEditView.cpp index 3a83194794a..df6a08079b3 100644 --- a/Src/MergeEditView.cpp +++ b/Src/MergeEditView.cpp @@ -578,7 +578,7 @@ std::map> CMergeEditView::GetColumnSelectedWordDiffIndice( { std::vector *pWordDiffs; if (list.find(firstDiff) == list.end()) - list.insert(std::pair *>(firstDiff, new std::vector())); + list.emplace(firstDiff, new std::vector()); pWordDiffs = list[firstDiff]; for (int i = firstWordDiff; i <= lastWordDiff; ++i) { @@ -589,7 +589,7 @@ std::map> CMergeEditView::GetColumnSelectedWordDiffIndice( } } for (auto& it : list) - ret.insert(std::pair>(it.first, *it.second)); + ret.emplace(it.first, *it.second); return ret; } @@ -1134,10 +1134,10 @@ void CMergeEditView::OnCurdiff() void CMergeEditView::OnUpdateCurdiff(CCmdUI* pCmdUI) { CMergeDoc *pd = GetDocument(); - CPoint pos = GetCursorPos(); int nCurrentDiff = pd->GetCurrentDiff(); if (nCurrentDiff == -1) { + CPoint pos = GetCursorPos(); int nNewDiff = pd->m_diffList.LineToDiff(pos.y); pCmdUI->Enable(nNewDiff != -1 && pd->m_diffList.IsDiffSignificant(nNewDiff)); } diff --git a/Src/MergeFrameCommon.cpp b/Src/MergeFrameCommon.cpp index 6bef940bb55..24943ea3dda 100644 --- a/Src/MergeFrameCommon.cpp +++ b/Src/MergeFrameCommon.cpp @@ -195,7 +195,6 @@ String CMergeFrameCommon::GetTooltipString(const PathContext& paths, const Strin sTitle += _("Right"); sTitle += _T("\n"); } - String flags; if (pInfoUnpacker && !pInfoUnpacker->GetPluginPipeline().empty()) sTitle += strutils::format(_T("%s: %s\n"), _("Unpacker"), pInfoUnpacker->GetPluginPipeline()); if (pInfoPrediffer && !pInfoPrediffer->GetPluginPipeline().empty()) diff --git a/Src/OpenView.cpp b/Src/OpenView.cpp index 9858b311e31..2f9db8996a0 100644 --- a/Src/OpenView.cpp +++ b/Src/OpenView.cpp @@ -564,7 +564,7 @@ void COpenView::OnPathButton(UINT nId) if (SelectFileOrFolder(GetSafeHwnd(), s, sfolder.c_str())) { m_strPath[index] = s; - m_strBrowsePath[index] = s; + m_strBrowsePath[index] = std::move(s); UpdateData(FALSE); UpdateButtonStates(); } @@ -807,7 +807,7 @@ void COpenView::OnLoadProject() { m_strPath[0] = paths[0]; m_strPath[1] = paths[1]; - m_strPath[2] = _T(""); + m_strPath[2].clear(); m_bReadOnly[0] = projItem.GetLeftReadOnly(); m_bReadOnly[1] = projItem.GetRightReadOnly(); m_bReadOnly[2] = false; @@ -936,7 +936,7 @@ void COpenView::OnSaveProject() void COpenView::DropDown(NMHDR* pNMHDR, LRESULT* pResult, UINT nID, UINT nPopupID) { - CRect rcButton, rcView; + CRect rcButton; GetDlgItem(nID)->GetWindowRect(&rcButton); BCMenu menu; VERIFY(menu.LoadMenu(nPopupID)); @@ -1338,7 +1338,6 @@ void COpenView::SetStatus(UINT msgID) */ void COpenView::OnSelectFilter() { - String filterPrefix = _("[F] "); String curFilter; auto* pGlobalFileFilter = theApp.GetGlobalFileFilter(); @@ -1359,6 +1358,7 @@ void COpenView::OnSelectFilter() } else { + String filterPrefix = _("[F] "); filterNameOrMask = filterPrefix + filterNameOrMask; SetDlgItemText(IDC_EXT_COMBO, filterNameOrMask); } diff --git a/Src/OptionsEditorSyntax.cpp b/Src/OptionsEditorSyntax.cpp index c38b8acb8ff..acd00381579 100644 --- a/Src/OptionsEditorSyntax.cpp +++ b/Src/OptionsEditorSyntax.cpp @@ -26,7 +26,7 @@ void GetDefaults(COptionsMgr* pOptionsMgr, String* pExtension) { String name = strutils::format(_T("%s/%s.exts"), Section, def->name); String exts = pOptionsMgr->GetDefault(name); - pExtension[i-1] = exts; + pExtension[i-1] = std::move(exts); } } } @@ -75,7 +75,7 @@ void Load(COptionsMgr *pOptionsMgr, String* pExtension) { String name = strutils::format(_T("%s/%s.exts"), Section, def->name); String exts = pOptionsMgr->GetString(name); - pExtension[i-1] = exts; + pExtension[i-1] = std::move(exts); } } } diff --git a/Src/OptionsFont.cpp b/Src/OptionsFont.cpp index 25b040f8e1b..ad2746c2811 100644 --- a/Src/OptionsFont.cpp +++ b/Src/OptionsFont.cpp @@ -17,7 +17,7 @@ namespace Options { namespace Font { * @brief Initialize basic default values in a LOGFONT structure. * A helper function for SetDefaults(); it should not be used otherwise. */ -void InitializeLogFont(LOGFONT &logfont, int lfHeight, int lfCharSet, int lfPitchAndFamily, String lfFaceName) +void InitializeLogFont(LOGFONT &logfont, int lfHeight, int lfCharSet, int lfPitchAndFamily, const String& lfFaceName) { logfont.lfHeight = lfHeight; logfont.lfWidth = 0; diff --git a/Src/OptionsFont.h b/Src/OptionsFont.h index 2e6a2e4461f..34dd7dd0843 100644 --- a/Src/OptionsFont.h +++ b/Src/OptionsFont.h @@ -8,7 +8,7 @@ class COptionsMgr; namespace Options { namespace Font { -//void InitializeLogFont(LOGFONT &logfont, int lfHeight, int lfCharSet, int lfPitchAndFamily, String lfFaceName); +//void InitializeLogFont(LOGFONT &logfont, int lfHeight, int lfCharSet, int lfPitchAndFamily, const String& lfFaceName); void Init(COptionsMgr *pOptionsMgr); LOGFONT Load(const COptionsMgr *pOptionsMgr, const String& name); void Save(COptionsMgr *pOptionsMgr, const String& name, const LOGFONT* lf, bool bUseCustom); diff --git a/Src/PatchDlg.cpp b/Src/PatchDlg.cpp index 503aeaa36b8..76ccc7ba408 100644 --- a/Src/PatchDlg.cpp +++ b/Src/PatchDlg.cpp @@ -118,9 +118,9 @@ void CPatchDlg::OnOK() PATCHFILES tFiles = m_fileList[0]; if (tFiles.lfile != m_file1 && !tFiles.pathLeft.empty()) - tFiles.pathLeft = _T(""); + tFiles.pathLeft.clear(); if (tFiles.rfile != m_file2 && !tFiles.pathRight.empty()) - tFiles.pathRight = _T(""); + tFiles.pathRight.clear(); tFiles.lfile = m_file1; tFiles.rfile = m_file2; m_fileList[0] = tFiles; diff --git a/Src/PatchTool.cpp b/Src/PatchTool.cpp index f9e47404da2..dba1bfc4d63 100644 --- a/Src/PatchTool.cpp +++ b/Src/PatchTool.cpp @@ -35,9 +35,7 @@ CPatchTool::CPatchTool() : m_bOpenToEditor(false), m_bCopyToClipbard(false) /** * @brief Default destructor. */ -CPatchTool::~CPatchTool() -{ -} +CPatchTool::~CPatchTool() = default; /** * @brief Adds files to list for patching. @@ -283,7 +281,7 @@ void CPatchTool::AddFilesToList(const String& sDir1, const String& sDir2, const if (!sDir1.empty()) pathLeft = sDir1 + backslash; pathLeft += ent1->filename.get(); - tFiles.pathLeft = pathLeft; + tFiles.pathLeft = std::move(pathLeft); } if (ent2 != nullptr) @@ -295,7 +293,7 @@ void CPatchTool::AddFilesToList(const String& sDir1, const String& sDir2, const pathRight = sDir2 + backslash; pathRight += ent2->filename.get(); - tFiles.pathRight = pathRight; + tFiles.pathRight = std::move(pathRight); } fileList->push_back(tFiles); diff --git a/Src/PathContext.h b/Src/PathContext.h index 133a97a395d..29c4e556ef6 100644 --- a/Src/PathContext.h +++ b/Src/PathContext.h @@ -20,7 +20,7 @@ class PathInfo { friend class PathContext; public: - PathInfo() {} + PathInfo() = default; String GetPath(bool bNormalized = true) const; String& GetRef() { return m_sPath; } @@ -114,7 +114,7 @@ class PathContextIterator : public std::iterator plugins) String nameNew = name + strutils::format(_T("(%d)"), i + 2); if (pluginNames.find(nameNew) == pluginNames.end()) { - name = nameNew; + name = std::move(nameNew); break; } } diff --git a/Src/PropertySystem.cpp b/Src/PropertySystem.cpp index 3879a5c9418..71739c89ed7 100644 --- a/Src/PropertySystem.cpp +++ b/Src/PropertySystem.cpp @@ -75,9 +75,7 @@ static bool CalculateHashValue(const String& path, const PROPERTYKEY& key, PROPV return false; } -PropertyValues::PropertyValues() -{ -} +PropertyValues::PropertyValues() = default; PropertyValues::~PropertyValues() { diff --git a/Src/SelectPluginDlg.cpp b/Src/SelectPluginDlg.cpp index 4cbde2e4c2f..bc9f0b26529 100644 --- a/Src/SelectPluginDlg.cpp +++ b/Src/SelectPluginDlg.cpp @@ -30,9 +30,9 @@ void CSelectPluginDlg::Initialize(PluginType pluginType) //{{AFX_DATA_INIT(CSelectPluginDlg) m_bNoExtensionCheck = false; m_bOpenInSameFrameType = false; - m_strDescription = _T(""); - m_strExtensions = _T(""); - m_strArguments = _T(""); + m_strDescription.clear(); + m_strExtensions.clear(); + m_strArguments.clear(); //}}AFX_DATA_INIT // texts for the default unpackers @@ -164,7 +164,7 @@ void CSelectPluginDlg::prepareListbox() m_cboPluginName.AddString(automaticPlugin->m_name.c_str()); } - std::vector processTypes; + std::list processTypes; for (const auto& [processType, pluginList] : m_Plugins) processTypes.push_back(processType); diff --git a/Src/SubeditList.cpp b/Src/SubeditList.cpp index 687c9db1c4d..64cefd80361 100644 --- a/Src/SubeditList.cpp +++ b/Src/SubeditList.cpp @@ -153,7 +153,7 @@ void CSubeditList::SetDropListFixedPattern(int nItem, int nSubItem, const String return; for (size_t i = m_dropListFixedPattern.size(); i <= static_cast(nItem); i++) - m_dropListFixedPattern.push_back(std::vector()); + m_dropListFixedPattern.emplace_back(std::initializer_list{}); for (size_t i = m_dropListFixedPattern[nItem].size(); i <= static_cast(nSubItem); i++) m_dropListFixedPattern[nItem].push_back(_T("")); diff --git a/Src/SubstitutionFiltersDlg.cpp b/Src/SubstitutionFiltersDlg.cpp index 2a887e52524..50f422e0e86 100644 --- a/Src/SubstitutionFiltersDlg.cpp +++ b/Src/SubstitutionFiltersDlg.cpp @@ -75,7 +75,7 @@ BOOL SubstitutionFiltersDlg::OnInitDialog() // EXCEPTION: OCX Property Pages should return FALSE } -static CString RemoveMnemonic(String text) +static CString RemoveMnemonic(const String& text) { Poco::RegularExpression re("\\(&.\\)|&|:"); std::string textu8 = ucr::toUTF8(text); diff --git a/Src/SubstitutionFiltersList.cpp b/Src/SubstitutionFiltersList.cpp index 4b572a30633..547fb512600 100644 --- a/Src/SubstitutionFiltersList.cpp +++ b/Src/SubstitutionFiltersList.cpp @@ -28,9 +28,7 @@ SubstitutionFiltersList::SubstitutionFiltersList() /** * @brief Destructor, empties the list. */ -SubstitutionFiltersList::~SubstitutionFiltersList() -{ -} +SubstitutionFiltersList::~SubstitutionFiltersList() = default; /** * @brief Add new filter to the list. diff --git a/Src/SubstitutionList.h b/Src/SubstitutionList.h index 473f34599a2..7f3f74dc253 100644 --- a/Src/SubstitutionList.h +++ b/Src/SubstitutionList.h @@ -26,7 +26,7 @@ struct SubstitutionItem class SubstitutionList { public: - SubstitutionList() {}; + SubstitutionList() = default; void Add(const std::string& pattern, const std::string& replacement, int regexpCompileOptions); void Add(const std::string& pattern, const std::string& replacement, bool caseSensitive, bool matchWholeWordOnly); diff --git a/Src/TempFile.cpp b/Src/TempFile.cpp index 6fe346cd7c2..64d0ae9deb8 100644 --- a/Src/TempFile.cpp +++ b/Src/TempFile.cpp @@ -50,7 +50,7 @@ String TempFile::Create(const String& prefix, const String& ext) { String tempext = temp + ext; if (MoveFile(temp.c_str(), tempext.c_str())) - temp = tempext; + temp = std::move(tempext); } m_path = temp; } @@ -68,7 +68,7 @@ bool TempFile::Delete() if (!m_path.empty()) success = !!DeleteFile(m_path.c_str()); if (success) - m_path = _T(""); + m_path.clear(); return success; } /** diff --git a/Src/TempFile.h b/Src/TempFile.h index 4c86541b8e5..476836800fe 100644 --- a/Src/TempFile.h +++ b/Src/TempFile.h @@ -16,7 +16,7 @@ class TempFile { public: - TempFile() {} + TempFile() = default; ~TempFile(); String Create(const String& prefix = _T(""), const String& ext = _T("")); /** diff --git a/Src/WMGotoDlg.cpp b/Src/WMGotoDlg.cpp index d2f505afd34..2144043e88b 100644 --- a/Src/WMGotoDlg.cpp +++ b/Src/WMGotoDlg.cpp @@ -86,6 +86,6 @@ END_MESSAGE_MAP() WMGotoDlg::WMGotoDlg() : m_pimpl(new WMGotoDlg::Impl(this)), m_nFile(-1), m_nGotoWhat(-1) {} -WMGotoDlg::~WMGotoDlg() {} +WMGotoDlg::~WMGotoDlg() = default; int WMGotoDlg::DoModal() { return static_cast(m_pimpl->DoModal()); } diff --git a/Src/paths.cpp b/Src/paths.cpp index a022245adc8..ddca36cf331 100644 --- a/Src/paths.cpp +++ b/Src/paths.cpp @@ -286,7 +286,7 @@ String GetLongPath(const String& szPath, bool bExpandEnvs) HANDLE h = FindFirstFile(TFile(sTemp).wpath().c_str(), &ffd); if (h == INVALID_HANDLE_VALUE) { - sLong = sTemp; + sLong = std::move(sTemp); if (ptr != nullptr) { sLong += '\\'; @@ -464,10 +464,10 @@ bool IsDirectory(const String &path) */ String ExpandShortcut(const String &inFile) { - assert(inFile != _T("")); + assert(!inFile.empty()); // No path, nothing to return - if (inFile == _T("")) + if (inFile.empty()) return _T(""); String outFile; diff --git a/Src/stringdiffs.cpp b/Src/stringdiffs.cpp index 662456babe7..afddab74c90 100644 --- a/Src/stringdiffs.cpp +++ b/Src/stringdiffs.cpp @@ -251,9 +251,7 @@ stringdiffs::stringdiffs(const String & str1, const String & str2, * @brief Destructor. * The destructor frees all diffs added to the vectors. */ -stringdiffs::~stringdiffs() -{ -} +stringdiffs::~stringdiffs() = default; #ifdef STRINGDIFF_LOGGING void