From da295330e97ee8d22914b7b523a7e55c08208a59 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Thu, 20 Aug 2015 00:08:22 +0200 Subject: [PATCH] Use IsEmpty()/empty() where possible Signed-off-by: Sven Strickroth --- src/Git/GitIndex.cpp | 5 ++--- src/Git/GitStatus.cpp | 2 +- src/TortoiseGitBlame/TortoiseGitBlameData.cpp | 2 +- src/TortoiseProc/AboutDlg.cpp | 2 +- src/TortoiseProc/AppUtils.cpp | 2 +- src/TortoiseProc/CloneDlg.cpp | 2 +- src/TortoiseProc/Commands/DropCopyCommand.cpp | 5 ++--- src/TortoiseProc/CommitDlg.cpp | 2 +- src/TortoiseProc/LogDlg.cpp | 4 ++-- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Git/GitIndex.cpp b/src/Git/GitIndex.cpp index abbfb48b4..076079420 100644 --- a/src/Git/GitIndex.cpp +++ b/src/Git/GitIndex.cpp @@ -1095,9 +1095,8 @@ bool CGitIgnoreList::IsIgnore(CString str, const CString& projectroot, bool isDi { str.Replace(_T('\\'),_T('/')); - if (str.GetLength()>0) - if (str[str.GetLength()-1] == _T('/')) - str = str.Left(str.GetLength() - 1); + if (!str.IsEmpty() && str[str.GetLength() - 1] == _T('/')) + str = str.Left(str.GetLength() - 1); int ret; ret = CheckIgnore(str, projectroot, isDir); diff --git a/src/Git/GitStatus.cpp b/src/Git/GitStatus.cpp index 335c9c486..7fe7dfe16 100644 --- a/src/Git/GitStatus.cpp +++ b/src/Git/GitStatus.cpp @@ -362,7 +362,7 @@ int GitStatus::EnumDirStatus(const CString &gitdir, const CString &subpath, git_ casepath += it->m_CaseFileName; bool bIsDir = false; - if (it->m_FileName.GetLength() > 0 && it->m_FileName[it->m_FileName.GetLength() - 1] == _T('/')) + if (!it->m_FileName.IsEmpty() && it->m_FileName[it->m_FileName.GetLength() - 1] == _T('/')) bIsDir = true; if (IsIgnore) diff --git a/src/TortoiseGitBlame/TortoiseGitBlameData.cpp b/src/TortoiseGitBlame/TortoiseGitBlameData.cpp index 82d997a5c..9c3495539 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameData.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameData.cpp @@ -352,7 +352,7 @@ int CTortoiseGitBlameData::FindNextLine(CGitHash& CommitHash, int line, bool bUp static int FindAsciiLower(const CStringA &str, const CStringA &find) { - if (find.GetLength() == 0) + if (find.IsEmpty()) return 0; for (int i = 0; i < str.GetLength(); ++i) diff --git a/src/TortoiseProc/AboutDlg.cpp b/src/TortoiseProc/AboutDlg.cpp index 1322604a1..02018c6ee 100644 --- a/src/TortoiseProc/AboutDlg.cpp +++ b/src/TortoiseProc/AboutDlg.cpp @@ -53,7 +53,7 @@ END_MESSAGE_MAP() static CString Lf2Crlf(const CString& text) { CString s; - if (text.GetLength() == 0) + if (text.IsEmpty()) return s; TCHAR c = '\0'; diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 6b11aec85..58044c5d6 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -2356,7 +2356,7 @@ int CAppUtils::SaveCommitUnicodeFile(const CString& filename, CString &message) line = line.Left(start - oldStart); ++start; // move forward so we don't find the same char again } - if (stripComments && (line.GetLength() >= 1 && line.GetAt(0) == '#') || (start < 0 && line.IsEmpty())) + if (stripComments && (!line.IsEmpty() && line.GetAt(0) == '#') || (start < 0 && line.IsEmpty())) continue; line.TrimRight(L" \r"); CStringA lineA = CUnicodeUtils::GetMulti(line + L"\n", cp); diff --git a/src/TortoiseProc/CloneDlg.cpp b/src/TortoiseProc/CloneDlg.cpp index 18b425143..37bd30dae 100644 --- a/src/TortoiseProc/CloneDlg.cpp +++ b/src/TortoiseProc/CloneDlg.cpp @@ -233,7 +233,7 @@ void CCloneDlg::OnOK() return; } - if (m_bOrigin && m_strOrigin.GetLength() == 0 && !m_bSVN) + if (m_bOrigin && m_strOrigin.IsEmpty() && !m_bSVN) { ShowEditBalloon(IDC_EDIT_ORIGIN, IDS_B_T_NOTEMPTY, IDS_ERR_ERROR, TTI_ERROR); m_bSaving = false; diff --git a/src/TortoiseProc/Commands/DropCopyCommand.cpp b/src/TortoiseProc/Commands/DropCopyCommand.cpp index 05e7288ee..90ce1c435 100644 --- a/src/TortoiseProc/Commands/DropCopyCommand.cpp +++ b/src/TortoiseProc/Commands/DropCopyCommand.cpp @@ -105,9 +105,8 @@ bool DropCopyCommand::Execute() CString path; path=fullDropPath.GetGitPathString().Mid(ProjectTopDir.GetLength()); - if(path.GetLength()>0) - if(path[0]==_T('\\') || path[0]==_T('/')) - path=path.Mid(1); + if (!path.IsEmpty() && (path[0] == _T('\\') || path[0] == _T('/'))) + path = path.Mid(1); cmd += path; cmd +=_T('\"'); diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index 413884eb3..c85cccefe 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -2171,7 +2171,7 @@ LRESULT CCommitDlg::OnUpdateOKButton(WPARAM, LPARAM) if (m_bBlock) return 0; - bool bValidLogSize = m_cLogMessage.GetText().GetLength() >= m_ProjectProperties.nMinLogSize && m_cLogMessage.GetText().GetLength() > 0; + bool bValidLogSize = !m_cLogMessage.GetText().IsEmpty() && m_cLogMessage.GetText().GetLength() >= m_ProjectProperties.nMinLogSize; bool bAmendOrSelectFilesOrMerge = m_ListCtrl.GetSelected() > 0 || (m_bCommitAmend && m_bAmendDiffToLastCommit) || CTGitPath(g_Git.m_CurrentDir).IsMergeActive(); DialogEnableWindow(IDOK, bValidLogSize && (m_bCommitMessageOnly || bAmendOrSelectFilesOrMerge)); diff --git a/src/TortoiseProc/LogDlg.cpp b/src/TortoiseProc/LogDlg.cpp index 083ef56bc..121917805 100644 --- a/src/TortoiseProc/LogDlg.cpp +++ b/src/TortoiseProc/LogDlg.cpp @@ -2455,7 +2455,7 @@ void CLogDlg::OnBnClickedJumpUp() found = data->ParentsCount() > 1; else if (jumpType == JumpType_Parent1) { - if (data->m_ParentHash.size() > 0) + if (!data->m_ParentHash.empty()) found = data->m_ParentHash[0] == hashValue; } else if (jumpType == JumpType_Parent2) @@ -2533,7 +2533,7 @@ void CLogDlg::OnBnClickedJumpDown() strValue = data->GetCommitterEmail(); else if (jumpType == JumpType_Parent1) { - if (data->m_ParentHash.size() > 0) + if (!data->m_ParentHash.empty()) hashValue = data->m_ParentHash.at(0); else return; -- 2.11.4.GIT