OSDN Git Service

PATCH: [ 1333581 ] Increase quick compare limit and make it option
authorKimmo Varis <kimmov@gmail.com>
Fri, 21 Oct 2005 13:50:19 +0000 (13:50 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 21 Oct 2005 13:50:19 +0000 (13:50 +0000)
Src/Changes.txt
Src/DiffContext.h
Src/DiffWrapper.cpp
Src/DirDoc.cpp
Src/OptionsDef.h
Src/OptionsInit.cpp

index 171f6eb..e092541 100644 (file)
@@ -1,6 +1,8 @@
 2005-10-21 Kimmo
  PATCH: [ 1333545 ] Small improvement to Open-dialog folder selection
   Src: OpenDlg.cpp
+ PATCH: [ 1333581 ] Increase quick compare limit and make it option
+  Src: DiffContext.h DiffWrapper.cpp DirDoc.cpp OptionsDef.h OptionsInit.cpp
 
 2005-10-20 Tim
  PATCH: [ 1330179 ] Icon for 'Print'
index 9d6bf41..b308630 100644 (file)
@@ -97,6 +97,7 @@ public:
        BOOL m_bIgnoreSmallTimeDiff; /**< Ignore small timedifferences when comparing by date */
        CompareStats *m_pCompareStats;
        BOOL m_bStopAfterFirstDiff; /**< Optimize compare by stopping after first difference? */
+       int m_nQuickCompareLimit; /**< Bigger files are always compared with quick compare */
 
 private:
        CList<DIFFITEM,DIFFITEM&> *m_pList; /**< Pointer to list, used to access list */
index ddda004..5e2f657 100644 (file)
@@ -50,15 +50,6 @@ extern int recursive;
 extern CLogFile gLog;
 static int f_defcp = 0; // default codepage
 static const int KILO = 1024; // Kilo(byte)
-static const int MEG = 1024 * KILO; // Mega(byte)
-
-/**
- * @brief Limit for compare by contents/quick contents.
- * If compare by contents is selected (normal) then files bigger than limit
- * are compared with compare by quick contents. That allows us to compare
- * big binary files and overall makes comparing bigger files faster.
- */
-static const int CMP_SIZE_LIMIT = 2 * MEG;
 
 /**
  * @brief Quick contents compare's file buffer size
@@ -1590,10 +1581,11 @@ int DiffFileData::prepAndCompareTwoFiles(CDiffContext * pCtxt, DIFFITEM &di)
                }
        }
 
-       // If either file is larger than 2 Megs compare files by quick contents
+       // If either file is larger than limit compare files by quick contents
        // This allows us to (faster) compare big binary files
        if (pCtxt->m_nCompMethod == CMP_CONTENT && 
-               (di.left.size > CMP_SIZE_LIMIT || di.right.size > CMP_SIZE_LIMIT))
+               (di.left.size > pCtxt->m_nQuickCompareLimit ||
+               di.right.size > pCtxt->m_nQuickCompareLimit))
        {
                nCompMethod = CMP_QUICK_CONTENT;
        }
index 6f09a20..1365803 100644 (file)
@@ -300,6 +300,7 @@ void CDirDoc::Rescan()
        m_pCtxt->m_nCompMethod = mf->m_options.GetInt(OPT_CMP_METHOD);
        m_pCtxt->m_bIgnoreSmallTimeDiff = mf->m_options.GetBool(OPT_IGNORE_SMALL_FILETIME);
        m_pCtxt->m_bStopAfterFirstDiff = mf->m_options.GetBool(OPT_CMP_STOP_AFTER_FIRST);
+       m_pCtxt->m_nQuickCompareLimit = mf->m_options.GetInt(OPT_CMP_QUICK_LIMIT);
        m_pCtxt->m_pCompareStats = m_pCompareStats;
 
        // Set total items count since we don't collect items
index 8fadfc9..2e7ced9 100644 (file)
@@ -104,6 +104,7 @@ const TCHAR OPT_CMP_EOL_SENSITIVE[] = _T("Settings/EolSensitive");
 const TCHAR OPT_CMP_METHOD[] = _T("Settings/CompMethod");
 const TCHAR OPT_CMP_MOVED_BLOCKS[] = _T("Settings/MovedBlocks");
 const TCHAR OPT_CMP_STOP_AFTER_FIRST[] = _T("Settings/StopAfterFirst");
+const TCHAR OPT_CMP_QUICK_LIMIT[] = _T("Settings/QuickMethodLimit");
 
 // Multidoc enable/disable per document type
 const TCHAR OPT_MULTIDOC_DIRDOCS[] = _T("Settings/MultiDirDocs");
index def58e0..a975602 100644 (file)
@@ -73,6 +73,7 @@ void CMainFrame::OptionsInit()
        m_options.InitOption(OPT_CMP_METHOD, (int)CMP_CONTENT);
        m_options.InitOption(OPT_CMP_MOVED_BLOCKS, false);
        m_options.InitOption(OPT_CMP_STOP_AFTER_FIRST, false);
+       m_options.InitOption(OPT_CMP_QUICK_LIMIT, 4 * 1024 * 1024); // 4 Megs
 
        m_options.InitOption(OPT_CLR_DIFF, (int)RGB(239,203,5));
        m_options.InitOption(OPT_CLR_SELECTED_DIFF, (int)RGB(239,119,116));