Commit dc2bf06b authored by Sven Strickroth's avatar Sven Strickroth

Use the emplace functions to insert objects into containers where appropriate

Inspired by TortoiseSVN rev. 26910.
Signed-off-by: Sven Strickroth's avatarSven Strickroth <email@cs-ware.de>
parent 0099bde6
......@@ -57,7 +57,7 @@ int GitRev::ParserParentFromCommit(GIT_COMMIT *commit)
git_get_commit_first_parent(commit,&list);
while(git_get_commit_next_parent(&list,parent)==0)
{
m_ParentHash.push_back(CGitHash((char *)parent));
m_ParentHash.emplace_back((char*)parent);
}
return 0;
}
......@@ -105,7 +105,7 @@ int GitRev::ParserParentFromCommit(const git_commit* commit)
m_ParentHash.clear();
unsigned int parentCount = git_commit_parentcount(commit);
for (unsigned int i = 0; i < parentCount; ++i)
m_ParentHash.push_back(CGitHash((char*)git_commit_parent_id(commit, i)->id));
m_ParentHash.emplace_back((char*)git_commit_parent_id(commit, i)->id);
return 0;
}
......
......@@ -68,7 +68,7 @@ int GitRevRefBrowser::GetGitRevRefMap(MAP_REF_GITREVREFBROWSER& map, CString& er
if (wcsncmp(refName, L"refs/heads/", 11) == 0)
ref.m_Description = descriptions[refName.Mid(11)];
map.insert(std::make_pair(refName, ref));
map.emplace(refName, ref);
}
return 0;
......
......@@ -178,7 +178,7 @@ void CGitBlameLogList::GetPaths(const CGitHash& hash, std::vector<CTGitPath>& pa
}
for (auto it = filenames.cbegin(); it != filenames.cend(); ++it)
{
paths.push_back(CTGitPath(*it));
paths.emplace_back(*it);
}
}
if (paths.empty())
......
......@@ -186,7 +186,7 @@ void CTortoiseGitBlameData::ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & Ha
int filenameEnd = lineEnd;
CStringA filenameA = CStringA((LPCSTR)&data[filenameBegin], filenameEnd - filenameBegin);
filename = UnquoteFilename(filenameA);
auto r = hashToFilename.insert(std::make_pair(hash, filename));
auto r = hashToFilename.emplace(hash, filename);
if (!r.second)
{
r.first->second = filename;
......@@ -225,8 +225,8 @@ void CTortoiseGitBlameData::ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & Ha
else
{
MessageBox(nullptr, err, _T("TortoiseGit"), MB_ICONERROR);
authors.push_back(CString());
dates.push_back(CString());
authors.emplace_back();
dates.emplace_back();
}
}
......@@ -475,7 +475,7 @@ GitRevLoglist* CTortoiseGitBlameData::GetRevForHash(CGitHashMap& HashToRev, cons
*err = rev.GetLastErr();
return nullptr;
}
it = HashToRev.insert(std::make_pair(hash, rev)).first;
it = HashToRev.emplace(hash, rev).first;
}
return &(it->second);
}
......
This diff is collapsed.
......@@ -65,16 +65,16 @@ bool BisectCommand::Execute()
if (path.HasSubmodules())
{
postCmdList.push_back(PostCmd(IDI_UPDATE, IDS_PROC_SUBMODULESUPDATE, []
postCmdList.emplace_back(IDI_UPDATE, IDS_PROC_SUBMODULESUPDATE, []
{
CString sCmd;
sCmd.Format(_T("/command:subupdate /bkpath:\"%s\""), (LPCTSTR)g_Git.m_CurrentDir);
CAppUtils::RunTortoiseGitProc(sCmd);
}));
});
}
if (!this->parser.HasKey(_T("reset")))
postCmdList.push_back(PostCmd(IDS_MENUBISECTRESET, []{ CAppUtils::RunTortoiseGitProc(_T("/command:bisect /reset")); }));
postCmdList.emplace_back(IDS_MENUBISECTRESET, []{ CAppUtils::RunTortoiseGitProc(_T("/command:bisect /reset")); });
};
INT_PTR ret = progress.DoModal();
......
......@@ -226,20 +226,20 @@ static bool DoCleanUp(const CTGitPathList& pathList, int cleanType, bool bDir, b
progress.m_PostCmdCallback = [&](DWORD status, PostCmdList& postCmdList)
{
if (status)
postCmdList.push_back(PostCmd(IDS_MSGBOX_RETRY, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, bDryRun, bNoRecycleBin); }));
postCmdList.emplace_back(IDS_MSGBOX_RETRY, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, bDryRun, bNoRecycleBin); });
if (status || !bDryRun)
return;
if (bNoRecycleBin)
{
postCmdList.push_back(PostCmd(IDS_CLEAN_NO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, TRUE); }));
postCmdList.push_back(PostCmd(IDS_CLEAN_TO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, FALSE); }));
postCmdList.emplace_back(IDS_CLEAN_NO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, TRUE); });
postCmdList.emplace_back(IDS_CLEAN_TO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, FALSE); });
}
else
{
postCmdList.push_back(PostCmd(IDS_CLEAN_TO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, FALSE); }));
postCmdList.push_back(PostCmd(IDS_CLEAN_NO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, TRUE); }));
postCmdList.emplace_back(IDS_CLEAN_TO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, FALSE); });
postCmdList.emplace_back(IDS_CLEAN_NO_RECYCLEBIN, [&]{ DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, TRUE); });
}
};
......
......@@ -181,7 +181,7 @@ bool CloneCommand::Execute()
{
if (status)
{
postCmdList.push_back(PostCmd(IDI_REFRESH, IDS_MSGBOX_RETRY, [&] { retry = true; }));
postCmdList.emplace_back(IDI_REFRESH, IDS_MSGBOX_RETRY, [&]{ retry = true; });
return;
}
......@@ -190,14 +190,14 @@ bool CloneCommand::Execute()
if (dlg.m_bAutoloadPuttyKeyFile) // do this here, since it might be needed for actions performed in Log
StorePuttyKey(dlg.m_Directory, dlg.m_bOrigin && !dlg.m_strOrigin.IsEmpty() ? dlg.m_strOrigin : _T("origin"), dlg.m_strPuttyKeyFile);
postCmdList.push_back(PostCmd(IDI_LOG, IDS_MENULOG, [&]
postCmdList.emplace_back(IDI_LOG, IDS_MENULOG, [&]
{
CString cmd = _T("/command:log");
cmd += _T(" /path:\"") + dlg.m_Directory + _T("\"");
CAppUtils::RunTortoiseGitProc(cmd);
}));
});
postCmdList.push_back(PostCmd(IDI_EXPLORER, IDS_STATUSLIST_CONTEXT_EXPLORE, [&]{ CAppUtils::ExploreTo(hWndExplorer, dlg.m_Directory); }));
postCmdList.emplace_back(IDI_EXPLORER, IDS_STATUSLIST_CONTEXT_EXPLORE, [&]{ CAppUtils::ExploreTo(hWndExplorer, dlg.m_Directory); });
};
// Handle Git SVN-clone
......
// TortoiseGit - a Windows shell extension for easy version control
// Copyright (C) 2008-2014 - TortoiseGit
// Copyright (C) 2008-2015 - TortoiseGit
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -73,19 +73,19 @@ bool SVNFetchCommand::Execute()
if (upstreamOldHash == upstreamNewHash)
return;
postCmdList.push_back(PostCmd(IDI_DIFF, _T("Fetched Diff"), [&]
postCmdList.emplace_back(IDI_DIFF, _T("Fetched Diff"), [&]
{
CLogDlg dlg;
dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash.ToString() + _T("..") + upstreamNewHash.ToString(), 0);
dlg.DoModal();
}));
});
postCmdList.push_back(PostCmd(IDI_LOG, _T("Fetched Log"), [&]
postCmdList.emplace_back(IDI_LOG, _T("Fetched Log"), [&]
{
CFileDiffDlg dlg;
dlg.SetDiff(NULL, upstreamNewHash.ToString(), upstreamOldHash.ToString());
dlg.DoModal();
}));
});
};
INT_PTR userResponse = progress.DoModal();
......
......@@ -996,12 +996,12 @@ void CCommitDlg::OnOK()
return;
if (IsGitSVN)
postCmdList.push_back(PostCmd(IDI_COMMIT, IDS_MENUSVNDCOMMIT, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_DCOMMIT; }));
postCmdList.emplace_back(IDI_COMMIT, IDS_MENUSVNDCOMMIT, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_DCOMMIT; });
postCmdList.push_back(PostCmd(IDI_PUSH, IDS_MENUPUSH, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_PUSH; }));
postCmdList.push_back(PostCmd(IDI_PULL, IDS_MENUPULL, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_PULL; }));
postCmdList.push_back(PostCmd(IDI_COMMIT, IDS_PROC_COMMIT_RECOMMIT, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_RECOMMIT; }));
postCmdList.push_back(PostCmd(IDI_TAG, IDS_MENUTAG, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_CREATETAG; }));
postCmdList.emplace_back(IDI_PUSH, IDS_MENUPUSH, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_PUSH; });
postCmdList.emplace_back(IDI_PULL, IDS_MENUPULL, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_PULL; });
postCmdList.emplace_back(IDI_COMMIT, IDS_PROC_COMMIT_RECOMMIT, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_RECOMMIT; });
postCmdList.emplace_back(IDI_TAG, IDS_MENUTAG, [&]{ m_PostCmd = GIT_POSTCOMMIT_CMD_CREATETAG; });
};
m_PostCmd = GIT_POSTCOMMIT_CMD_NOTHING;
......@@ -1675,7 +1675,7 @@ void CCommitDlg::GetAutocompletionList()
if (PathFileExists(sSnippetFile))
ParseSnippetFile(sSnippetFile, m_snippet);
for (const auto& snip : m_snippet)
m_autolist.insert(std::make_pair(snip.first, AUTOCOMPLETE_SNIPPET));
m_autolist.emplace(snip.first, AUTOCOMPLETE_SNIPPET);
DWORD starttime = GetTickCount();
......@@ -1699,7 +1699,7 @@ void CCommitDlg::GetAutocompletionList()
continue;
CString sPartPath =path->GetGitPathString();
m_autolist.insert(std::make_pair(sPartPath, AUTOCOMPLETE_FILENAME));
m_autolist.emplace(sPartPath, AUTOCOMPLETE_FILENAME);
int pos = 0;
int lastPos = 0;
......@@ -1707,7 +1707,7 @@ void CCommitDlg::GetAutocompletionList()
{
++pos;
lastPos = pos;
m_autolist.insert(std::make_pair(sPartPath.Mid(pos), AUTOCOMPLETE_FILENAME));
m_autolist.emplace(sPartPath.Mid(pos), AUTOCOMPLETE_FILENAME);
}
// Last inserted entry is a file name.
......@@ -1716,7 +1716,7 @@ void CCommitDlg::GetAutocompletionList()
{
int dotPos = sPartPath.ReverseFind('.');
if ((dotPos >= 0) && (dotPos > lastPos))
m_autolist.insert(std::make_pair(sPartPath.Mid(lastPos, dotPos - lastPos), AUTOCOMPLETE_FILENAME));
m_autolist.emplace(sPartPath.Mid(lastPos, dotPos - lastPos), AUTOCOMPLETE_FILENAME);
}
if (path->m_Action == CTGitPath::LOGACTIONS_UNVER && !CRegDWORD(_T("Software\\TortoiseGit\\AutocompleteParseUnversioned"), FALSE))
......@@ -1799,7 +1799,7 @@ void CCommitDlg::ScanFile(const CString& sFilePath, const CString& sRegex, const
{
if (match[i].second-match[i].first)
{
m_autolist.insert(std::make_pair(std::wstring(match[i]).c_str(), AUTOCOMPLETE_PROGRAMCODE));
m_autolist.emplace(std::wstring(match[i]).c_str(), AUTOCOMPLETE_PROGRAMCODE);
}
}
}
......
......@@ -88,12 +88,12 @@ bool AddProgressCommand::Run(CGitProgressList* list, CString& sWindowTitle, int&
if (status)
return;
postCmdList.push_back(PostCmd(IDI_COMMIT, IDS_MENUCOMMIT, []
postCmdList.emplace_back(IDI_COMMIT, IDS_MENUCOMMIT, []
{
CString sCmd;
sCmd.Format(_T("/command:commit /path:\"%s\""), (LPCTSTR)g_Git.m_CurrentDir);
CAppUtils::RunTortoiseGitProc(sCmd);
}));
});
};
return true;
......
......@@ -50,12 +50,12 @@ bool ResolveProgressCommand::Run(CGitProgressList* list, CString& sWindowTitle,
if (status)
return;
postCmdList.push_back(PostCmd(IDI_COMMIT, IDS_MENUCOMMIT, []
postCmdList.emplace_back(IDI_COMMIT, IDS_MENUCOMMIT, []
{
CString sCmd;
sCmd.Format(_T("/command:commit /path:\"%s\""), (LPCTSTR)g_Git.m_CurrentDir);
CAppUtils::RunTortoiseGitProc(sCmd);
}));
});
};
return true;
......
......@@ -452,12 +452,12 @@ void CSyncDlg::FetchComplete()
if (status && g_Git.HasWorkingTreeConflicts())
{
// there are conflict files
postCmdList.push_back(PostCmd(IDI_RESOLVE, IDS_PROGRS_CMD_RESOLVE, []
postCmdList.emplace_back(IDI_RESOLVE, IDS_PROGRS_CMD_RESOLVE, []
{
CString sCmd;
sCmd.Format(_T("/command:commit /path:\"%s\""), g_Git.m_CurrentDir);
CAppUtils::RunTortoiseGitProc(sCmd);
}));
});
}
};
mergeProgress.DoModal();
......
......@@ -732,7 +732,7 @@ void CSciEdit::DoAutoCompletion(int nMinPrefixLength)
continue;
else if (compare == 0)
{
wordset.insert(std::make_pair(lowerit->first, lowerit->second));
wordset.emplace(lowerit->first, lowerit->second);
}
else
{
......
......@@ -388,7 +388,7 @@ bool CReaderWriterLock::AcquireReaderLock(DWORD dwTimeout)
// There is NO WRITER on this RW object
// Current thread is going to be a READER
++m_impl.m_iNumOfReaderEntered;
m_map.insert(std::make_pair(dwCurrentThreadId, READER_RECURRENCE_UNIT));
m_map.emplace(dwCurrentThreadId, READER_RECURRENCE_UNIT);
m_impl.LeaveCS();
return TRUE;
......@@ -403,7 +403,7 @@ bool CReaderWriterLock::AcquireReaderLock(DWORD dwTimeout)
bool blCanRead = m_impl._ReaderWait(dwTimeout);
if(blCanRead)
{
m_map.insert(std::make_pair(dwCurrentThreadId, READER_RECURRENCE_UNIT));
m_map.emplace(dwCurrentThreadId, READER_RECURRENCE_UNIT);
}
m_impl.LeaveCS();
......@@ -479,7 +479,7 @@ bool CReaderWriterLock::AcquireWriterLock(DWORD dwTimeout)
// This RW object is not owned by any thread
// --> it's safe to make this thread to be WRITER
++m_impl.m_iNumOfWriter;
m_map.insert(std::make_pair(dwCurrentThreadId, WRITER_RECURRENCE_UNIT));
m_map.emplace(dwCurrentThreadId, WRITER_RECURRENCE_UNIT);
m_impl.LeaveCS();
return TRUE;
}
......@@ -494,7 +494,7 @@ bool CReaderWriterLock::AcquireWriterLock(DWORD dwTimeout)
if(blCanWrite)
{
m_impl.EnterCS();
m_map.insert(std::make_pair(dwCurrentThreadId, WRITER_RECURRENCE_UNIT));
m_map.emplace(dwCurrentThreadId, WRITER_RECURRENCE_UNIT);
}
m_impl.LeaveCS();
}
......
......@@ -94,7 +94,7 @@ int CSysImageList::GetPathIconIndex(const CTGitPath& filePath) const
{
// We don't have this extension in the map
int iconIndex = GetFileIconIndex(filePath.GetFilename());
it = m_indexCache.insert(it, std::make_pair(strExtension, iconIndex));
it = m_indexCache.emplace_hint(it, strExtension, iconIndex);
}
// We must have found it
return it->second;
......
......@@ -1048,7 +1048,7 @@ T& CKeyList<T>::GetAt (int index) const
typename T::StringT indexKey = key + _T ('\\') + buffer;
T* newElement = new T (indexKey, GetDefault (index), false, base);
iter = elements.insert (std::make_pair (index, newElement)).first;
iter = elements.emplace(index, newElement).first;
}
return *iter->second;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment