From dcccc3a0643cc381b4299594eeb1bf3ee8482dfc Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Tue, 26 Feb 2013 22:14:42 +0800 Subject: [PATCH] Boost performance of Progress Dialog if the command line output is long To test, commit 10000 files Signed-off-by: Sup Yut Sum --- src/TortoiseProc/ProgressDlg.cpp | 24 ++++-------------------- src/TortoiseProc/ProgressDlg.h | 1 - 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/TortoiseProc/ProgressDlg.cpp b/src/TortoiseProc/ProgressDlg.cpp index ee237afc5..5a6bcdf54 100644 --- a/src/TortoiseProc/ProgressDlg.cpp +++ b/src/TortoiseProc/ProgressDlg.cpp @@ -202,6 +202,7 @@ UINT CProgressDlg::RunCmdList(CWnd *pWnd,std::vector &cmdlist,bool bSho g_Git.RunAsync(cmdlist[i].Trim(),&pi, &hRead, NULL, pfilename); DWORD readnumber; + char lastByte = '\0'; char byte; CString output; while(ReadFile(hRead,&byte,1,&readnumber,NULL)) @@ -212,7 +213,10 @@ UINT CProgressDlg::RunCmdList(CWnd *pWnd,std::vector &cmdlist,bool bSho byte = '\n'; pdata->m_critSec.Lock(); + if (byte == '\n' && lastByte != '\r') + pdata->push_back('\r'); pdata->push_back( byte); + lastByte = byte; pdata->m_critSec.Unlock(); if(byte == '\r' || byte == '\n') @@ -288,9 +292,6 @@ LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam) { m_Databuf.m_critSec.Lock(); m_Databuf.push_back(0); - m_Databuf.m_critSec.Unlock(); - InsertCRLF(); - m_Databuf.m_critSec.Lock(); m_Log.SetWindowText(Convert2UnionCode((char*)&m_Databuf[0])); m_Databuf.m_critSec.Unlock(); m_Log.LineScroll(m_Log.GetLineCount() - m_Log.GetFirstVisibleLine() - 4); @@ -621,23 +622,6 @@ void CProgressDlg::KillProcessTree(DWORD dwProcessId, unsigned int depth) } } -void CProgressDlg::InsertCRLF() -{ - m_Databuf.m_critSec.Lock(); - for (int i = 0; i < m_Databuf.size(); ++i) - { - if(m_Databuf[i]==('\n')) - { - if(i==0 || m_Databuf[i-1]!= ('\r')) - { - m_Databuf.insert(m_Databuf.begin()+i,('\r')); - ++i; - } - } - } - m_Databuf.m_critSec.Unlock(); -} - void CProgressDlg::InsertColorText(CRichEditCtrl &edit,CString text,COLORREF rgb) { CHARFORMAT old,cf; diff --git a/src/TortoiseProc/ProgressDlg.h b/src/TortoiseProc/ProgressDlg.h index 20795da6a..d835e59cd 100644 --- a/src/TortoiseProc/ProgressDlg.h +++ b/src/TortoiseProc/ProgressDlg.h @@ -95,7 +95,6 @@ private: void OnCancel(); afx_msg void OnClose(); - void InsertCRLF(); //Insert \r before \n void KillProcessTree(DWORD dwProcessId, unsigned int depth = 0); CGitByteArray m_Databuf; -- 2.11.4.GIT