Skip to content

[Big PR - big changes] A lot of refactor and optimization commits #1258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ShellExtension/Common/WinMergeContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ bool WinMergeContextMenu::UpdateMenuState(const std::vector<std::wstring>& paths
std::vector<MenuItem> WinMergeContextMenu::GetMenuItemList() const
{
std::vector<MenuItem> 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;
Expand Down
3 changes: 2 additions & 1 deletion Src/7zCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Src/AboutDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(m_pimpl->DoModal()); }
6 changes: 2 additions & 4 deletions Src/Common/BCMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ HTHEME BCMenu::m_hTheme = nullptr;
static class GdiplusToken
{
public:
GdiplusToken()
{
}
GdiplusToken() = default;

~GdiplusToken()
{
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/MDITabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions Src/Common/OptionsMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ varprop::VariantValue COptionsMgr::m_emptyValue;
/**
* @brief Default constructor.
*/
COption::COption()
{
}
COption::COption() = default;

/**
* @brief Copy constructor.
Expand Down
3 changes: 1 addition & 2 deletions Src/Common/PreferencesDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion Src/Common/RegOptionsMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Src/Common/ShellContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/SplitterWndEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/SuperComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion Src/Common/lwdisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/multiformatText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/scbarcf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/scbarcf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/scbarg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/scbarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Src/Common/sizecbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Src/Common/sizecbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions Src/CompareEngines/BinaryCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ BinaryCompare::BinaryCompare() : m_piAbortable(nullptr)
{
}

BinaryCompare::~BinaryCompare()
{
}
BinaryCompare::~BinaryCompare() = default;

/**
* @brief Set Abortable-interface.
Expand Down
4 changes: 1 addition & 3 deletions Src/CompareEngines/ByteCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ ByteCompare::ByteCompare()
/**
* @brief Default destructor.
*/
ByteCompare::~ByteCompare()
{
}
ByteCompare::~ByteCompare() = default;

/**
* @brief Set compare options from general compare options.
Expand Down
4 changes: 1 addition & 3 deletions Src/CompareEngines/TimeSizeCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ TimeSizeCompare::TimeSizeCompare()
{
}

TimeSizeCompare::~TimeSizeCompare()
{
}
TimeSizeCompare::~TimeSizeCompare() = default;

/**
* @brief Set compare-type specific options.
Expand Down
4 changes: 1 addition & 3 deletions Src/CompareStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ CompareStats::CompareStats(int nDirs)
/**
* @brief Destructor, deletes critical section.
*/
CompareStats::~CompareStats()
{
}
CompareStats::~CompareStats() = default;

/**
* @brief Add compared item.
Expand Down
6 changes: 3 additions & 3 deletions Src/ConfigLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 1 addition & 3 deletions Src/DiffContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Src/DiffFileInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct DiffFileInfo : public DirItem

// methods

DiffFileInfo() { }
DiffFileInfo() = default;
//void Clear();
void ClearPartial();
bool IsEditableEncoding() const;
Expand Down
6 changes: 2 additions & 4 deletions Src/DiffList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand All @@ -75,7 +73,7 @@ class DiffMap

std::vector<int> m_map;

DiffMap() { }
DiffMap() = default;
void InitDiffMap(int nlines);
};

Expand Down
2 changes: 1 addition & 1 deletion Src/DiffTextBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 2 additions & 4 deletions Src/DiffWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ CDiffWrapper::CDiffWrapper()
/**
* @brief Destructor.
*/
CDiffWrapper::~CDiffWrapper()
{
}
CDiffWrapper::~CDiffWrapper() = default;

/**
* @brief Enables/disables patch-file creation and sets filename.
Expand Down Expand Up @@ -1476,7 +1474,7 @@ const SubstitutionList* CDiffWrapper::GetSubstitutionList() const

void CDiffWrapper::SetSubstitutionList(std::shared_ptr<SubstitutionList> pSubstitutionList)
{
m_pSubstitutionList = pSubstitutionList;
m_pSubstitutionList = std::move(pSubstitutionList);
}

void CDiffWrapper::SetFilterCommentsSourceDef(const String& ext)
Expand Down
2 changes: 1 addition & 1 deletion Src/DiffWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Src/DirActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/DirCmpReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Src/DirItemIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DirItemWithIndexIterator : public std::iterator<std::forward_iterator_tag,
{
}

~DirItemWithIndexIterator() {}
~DirItemWithIndexIterator() = default;

DirItemWithIndexIterator& operator=(const DirItemWithIndexIterator& it)
{
Expand Down Expand Up @@ -130,7 +130,7 @@ class DirItemIterator : public std::iterator<std::forward_iterator_tag, DIFFITEM
{
}

~DirItemIterator() {}
~DirItemIterator() = default;

DirItemIterator::DirItemIterator(const DirItemIterator& it)
{
Expand Down
Loading